问些问题,顶者有分
以下都在标准C++(stl)下:
1, const char*
char *
与string 的区别
2.exit(1);与
return;
区别
3.vector <string> vec;
这里vec的 初值是什么
vector<string>::iterator it;
it=vec.begin();
int i=vec[0];
这样看来iterator与整数i有什么区别吗
4.在类定义里含有:
public:
OneSent(string str);
void getRealNodes(const ParseNode* node,vector <ParseNode*> &realNodes);
Path getPath(ParseNode* node1,ParseNode* node2);
void getAllPaths(vector <ParseNode*> realNodes, vector<Path> &allPaths);
private:
ParseNode* rootNode;
实现如下:
void getReltoRoot(ParseNode* n,vector<string> &reltoRoot)
{
ParseNode* node=(ParseNode*) n;
while(node != rootNode){
}
}
却报错:testOndSent.cpp(53) : error C2065: 'rootNode' : undeclared identifier
在rootNode前加上this.
报错为 :
testOndSent.cpp(53) : error C2673: 'getReltoRoot' : global functions do not have 'this' pointers
testOndSent.cpp(53) : error C2228: left of '.rootNode' must have class/struct/union type
testOndSent.cpp(53) : fatal error C1903: unable to recover from previous error(s); stopping compilation
请问:rootNode 在类定义中已经含有了,为什么找不到?
this,不可以这样用吗,应该怎么用呢 ?