C:\Documents and Settings\Administrator\桌面\Lift\LiftDlg.cpp(435) : error C2352: 'CLiftButton::LiftGoTo' : illegal call of non-static member function这个错误提示信息是怎么回事啊? 请教!
Compiler Error C2352 'class::function' : illegal call of non-static member functionThe specified nonstatic member function was called in a static member function.The following is an example of this error:class X { public: static void func1(); void func2(); static void func3() { func1(); // OK, calls static func1 func2(); // error, calls nonstatic func2 } };-----MSDN。
class X
{
public:
static void func1();
void func2();
static void func3()
{
func1(); // OK, calls static func1
func2(); // error, calls nonstatic func2
}
};
注释:
func3调用func2的时候出现了错误,这是因为func3是static成员函数,调用它的时候不存在this指针,但是fun2是普通的成员函数,必须在this指针作用域里面才能被调用。这两者矛盾,所以错误。
'class::function' : illegal call of non-static member functionThe specified nonstatic member function was called in a static member function.The following is an example of this error:class X
{
public:
static void func1();
void func2();
static void func3()
{
func1(); // OK, calls static func1
func2(); // error, calls nonstatic func2
}
};-----MSDN。