【发布时间】:2012-02-02 16:58:57
【问题描述】:
所以我有这个:
class A
{
private:
unsigned int _uid; //user identifier
public:
A();
A(const char *, const char *, int, int, const char *, const char *, const char *);
virtual ~A();
int getUserID();
};
int A::getUserID(){
return _uid;
}
//The class UserDB is not that important as this method is at this moment.
void UserDB::adduser(A* newUser){
if(newUser.getUserID == 0) //Not working, not sure why... Gives syntax error. (1)
//Something is done if the condition is true;
};
int main(){
UserDB B
A tempObj;
//Assume the 7 following variables have been initialized correctly.
char uloginName[9];
char homeDirectory[33];
int userID;
int groupID;
char password[17];
char shell[17];
char gecos[65];
tempObj = new A(uloginName, password, userID, groupID, gecos, homeDirectory, shell);
B = new UserDB();
B.addUser(tempObj);
}
所以不知何故,我无法获取参数指针以使用访问器方法(参见 (1) 标记的行)。有人可以给我一个快速修复吗?我搜索了一种方法来做到这一点,但似乎没有人拥有参数是指向对象的指针的访问器。
【问题讨论】:
-
我可以告诉您来自具有不同
new语法的语言。也许是java? :)
标签: c++ syntax-error