我需要致电我的公共成员。构造函数需要1个参数。使用** ClassObject调用公共成员(C++)
这是我的代码的外观: //主
char tmpArray[100] = {};
while (!inFile.eof())
{
for (unsigned x = 0; x < str2.length(); x++)
{
if (!isspace(str2[x]) || isspace(str2[x]))
{
tmpArray[x] = str2[x]; // prepare to supply the constructor with each word
ClassObject[wrdCount] = new ClassType[x] ;
//ClassObject[wordCount]->ClassType(tmpArray);
}
}
}
的错误是:
'功能样式转换':非法作为 右侧 ' - >' 操作
要尝试解决问题,我尝试两个等效表达式:
/* no good */ (*ClassObject[wrdCount]).ClassType(tmpArray);
/* no good */ (*ClassObject[wrdCount][10]).ClassType(tmpArray);
/* combine */ ClassObject[arbitrary][values]->ClassType(tmpArray);
智能感知确实会带出除构造函数之外的所有我的成员和私有者。 这可能是原因吗?
//MyHeader.h
class ClassObject
{
private:
const char* cPtr;
float theLength;
public:
ClassObject(const char*); // Yes its here and saved..
ClassObject(); // an appropriate default constructor
~ClassObject();
char GetThis();
char* GetThat();
}
你能发布整个代码吗?我不明白你是如何拥有一个ClassObject类的,并且也使用ClassObject作为指针。 – Uri 2009-04-12 05:33:41
我是否缺少某些东西,或者是“if(!isspace(str2 [x])|| isspace(str2 [x]))”总是会评估为true? – Venesectrix 2009-04-13 15:53:22