【发布时间】:2013-11-21 09:31:36
【问题描述】:
我有一个这样定义的类(在 wxWidgets 框架中):
class SomePanel : public wxPanel{
public:
...
void SomeMethod(const std::string& id){
pointer->UseId(id);
}
const std::string id = "Text"; // still in public area
...
}
在 pogram 的其他地方,我创建了对该对象实例的引用...
mSomePanel = new SomePanel();
...那我想做这个
mSomePanel->SomeMethod(mSomePanel->id); // Compiler gives an error saying that
// there is no element named id.
在(的)类中,我可以使用这个成员变量调用相同的方法。问题出在哪里?
【问题讨论】:
-
id 是 SomePanel 的成员,传递给 self 有什么意义?
-
粘贴的代码不完整。 (请只编译粘贴)
标签: c++ methods reference arguments argument-passing