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
請指教。謝謝。
馬丁格式化源代碼對你,但你應該這樣更有意義自己格式化,當你擁有所有的標籤和回報,你可以很容易地發現在它的錯誤.. – Zenuka 2009-10-23 07:47:56