【发布时间】:2009-10-23 07:37:49
【问题描述】:
我有
class Node
{
public:
string el1;
string el2;
string curr;
string name;
int ID1;
int ID2;
Node(){
//constructor is here
ID1=-1;
ID2=-1;
}
};
它有10个用数组表示的不同节点..
Node [] allNode=new Node[10];
for(i=0; i< 10; i++)
{
//create new node
allNode[i] = new Node();
std::string el = "f";
std::string el2 = "g";
std::string allNode[i].curr;
allNode[i].curr = name + boost::lexical_cast<std::string>(i);
cout << "Node name " << allNode[i].curr <<endl;
}
但是,我编译错误如下:-
error: expected unqualified-id before ‘[’ token referring to Node [] allNode=new Node[10];
error: ‘allNode’ was not declared in this scope
error: ‘name’ was not declared in this scope
请指教。谢谢。
【问题讨论】:
-
Martin 为您格式化了源代码,但您应该自己格式化它,这样更有意义,并且当您拥有所有选项卡并返回时,您可以轻松发现其中的错误..
标签: c++ compiler-errors