Cam*_*mel 0 c++ namespaces class
可能答案是相当愚蠢但我需要一双新鲜的眼睛来发现问题,如果你愿意的话.这是_tmain的摘录:
Agent theAgent(void);
int m = theAgent.loadSAG();
Run Code Online (Sandbox Code Playgroud)
这是agent.h,我包含在_tmain中:
#ifndef AGENT_H
#define AGENT_H
class Agent {
public:
Agent(void);
int loadSAG(void);
~Agent(void);
};
#endif
Run Code Online (Sandbox Code Playgroud)
和agent.cpp相关的功能:
int Agent::loadSAG(void) {
return 3;
}
Run Code Online (Sandbox Code Playgroud)
那么为什么在世界上我得到这个错误:错误C2228:'.loadSAG'的左边必须有class/struct/union?
提前致谢.
Agent theAgent(void);
Run Code Online (Sandbox Code Playgroud)
这是一个函数声明,只需将其更改为:
Agent theAgent;
Run Code Online (Sandbox Code Playgroud)