小编use*_*388的帖子

列表节点指针'未在此范围内声明'?

我已经搜索了高低,试图调试这个,但到目前为止我无法弄明白.

我在一个名为DataList.h的文件中有一个类声明,一个名为DataList.cc文件的文件中的方法,以及一个单独的.cc文件中的主程序.

DataList.cc有一个#include头,包含DataList.h.

每当我跑

g++ DataList.cc
Run Code Online (Sandbox Code Playgroud)

在Ubuntu终端,它吐出来

DataList.cc: In function ‘bool TransactOnce(int&, TRANS&, std::string&)’:
DataList.cc:395:2: error: ‘ListNodeT’ was not declared in this scope
DataList.cc:395:13: error: ‘nodeTPtr’ was not declared in this scope
DataList.cc:396:13: error: ‘headTrans’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

奇怪的是,我在DataList.cc中的其他成员函数中声明了这些类型的变量ALL OVER THE PLACE,但编译器除了上面的那些之外没有给我任何其他错误.我试图找出g ++不喜欢那个函数中那些特定声明的内容.

'ListNodeT'是我的主类中的结构,结构包含指向另一个结构类型对象的指针.'nodeTPtr'只是指向'ListNodeT'对象的指针,'headTrans'是指向ListNodeT类型的对象的指针(私有地包含在类中),特别是链表中的第一个节点.

"列表"类用于链表.

这是"DataList.h"文件:

#ifndef DATALIST_H
#define DATALIST_H

#include <iostream>
#include <fstream>
#include <ostream>
#include <iomanip>

using namespace std;
const int MAXDISCIPLINES = 4;
const int MAXBREEDS = 4;
struct HORSE {
    int    ID;
    string …
Run Code Online (Sandbox Code Playgroud)

c++ g++ linked-list list

2
推荐指数
1
解决办法
3516
查看次数

8086汇编:MOV部分字符串变为变量

假设我有一串ascii字符,例如"652 + 346*779 =",我想将一些字符从这个变量移到另一个变量......

缓冲区是字符串(在本例中为"652 + 346*779 =")lengthofnum是有问题的数字的长度(在这种情况下,346的长度为3)A_ascii是我正在尝试传输字符串的变量" 346" .

我有一个根本不起作用的循环,我无法弄清楚我应该使用什么寻址模式.emu8086讨厌到目前为止我尝试过的所有内容,并且使用MOV指令给出了关于语法的错误

mov cx,lengthofnum
dumploop1:
    mov bx, offset buffer
    ;dump the number from buffer into A_ascii
    mov A_ascii[cx],[bx]+cx
loop dumploop1:
Run Code Online (Sandbox Code Playgroud)

我收到以下错误代码:

(672) wrong parameters: MOV  A_ascii[cx],[bx]+cx

(672) probably it's an undefined var: A_ascii[cx] 
Run Code Online (Sandbox Code Playgroud)

x86 assembly addressing mov

1
推荐指数
1
解决办法
7878
查看次数

(C++)将指向动态分配的数组的指针传递给函数

我有变量在内存中互相覆盖的问题,所以我决定尝试动态分配我的一个数组.

在下面的简化代码中,我试图使用动态分配创建一个整数数组,然后让函数编辑整数数组中的值.一旦函数完成执行,我想要一个处理得很好的数组用于其他函数.

据我所知,数组不能传递给函数,所以我只是将指向数组的指针传递给函数.

#include <iostream>
using namespace std;

void func(int *[]);


int main(){


    //dynamically allocate an array
    int *anArray[100];
    anArray[100] = new int [100];


    func(anArray);

    int i;
    for (i=0; i < 99; i++)
        cout << "element " << i << " is: " << anArray[i] << endl;

delete [] anArray;
}

void func(int *array[]){
    //fill with 0-99
    int i;
    for (i=0; i < 99; i++){
        (*array)[i] = i;
        cout << "element " << i << " is: " …
Run Code Online (Sandbox Code Playgroud)

c++ pointers allocation core dynamic

1
推荐指数
1
解决办法
3724
查看次数

标签 统计

c++ ×2

addressing ×1

allocation ×1

assembly ×1

core ×1

dynamic ×1

g++ ×1

linked-list ×1

list ×1

mov ×1

pointers ×1

x86 ×1