//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