//ClassA.h
Class ClassA
{
private:
UtilityClass utilityCls; // this is the instance that I need to access
virtual void Read();
static bool IsValid(char c);
}
//ClassA.cpp
void ClassA::Read()
{
....
string str = "abcdefg"; // sample only
if(find_if(str.begin(), str.end(), IsValid) == str.end())
{
....
}
}
inline bool IsValid(char c)
{
// There are compile errors When I call functions of Utility class here
// Ex: utilityCls.ProcessData();
return (isalpha(c)); // sample only
}
我真的需要訪問「IsValid」函數內的「utilityCls」。有沒有簡單的方法來做到這一點?或者還有其他方法或解決方法嗎?對不起,如果這是一個愚蠢的問題。請幫助我們......如何訪問靜態函數內的其他類實例變量
請發佈*真實*代碼。這甚至不會編譯 – 2010-11-17 22:44:36