的成員函數我有一個類(在wxWidgets的框架)那樣定義:C++無法公共常量字符串構件傳遞作爲參數傳遞給同一類
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的成員,將它傳遞給自我有什麼意義? – billz
粘貼的代碼不完整。 (請僅編譯粘貼) –