我有以下程序片段:
Polynomial Polynomial:: add(const Polynomial b)
{
Polynomial c;
c.setRoot(internalAdd(root, c.root));
c.setRoot(internalAdd(b.root, c.root));
return c;
}
c = (a.add(b));
Run Code Online (Sandbox Code Playgroud)
据我所知,这段代码假设将a和b加在一起,然后通过调用复制构造函数将结果多项式赋值给c.
但是,当我真正测试它时,
我该怎么做才能解决这个问题?
以下是我的index.h类
class index
{
struct node {
string item;
int counter;
vector<int> pageNumber;
};
public:
node* newNode (string word);
...
private:
vector<node*> indexStructure;
int lineCounter;
int indexSize;
};
Run Code Online (Sandbox Code Playgroud)
在我的index.cpp类中,我有一个方法定义如下:
node* index::newNode (string word)
{
node* temp = new node();
temp.item = word;
temp.counter = 1;
temp.pageNumber = new vector <int> (10, -1);
temp.pageNumber[0] = lineCounter / 40;
return temp;
}
Run Code Online (Sandbox Code Playgroud)
当我编译时,它告诉我"节点没有命名类型",即使它在index.h中的结构中定义,并且我的私有向量变量可以具有类型node*.