在类外t:f()不行呢?解决方法
在类外t::f()不行呢?
class t{
public:
virtual void f(){}
};
class s:public t{
public:
void f(){t::f();}
};
int _tmain(int argc, _TCHAR* argv[])
{
t::f();
return 0;
}
------解决方案--------------------
因为在类成员函数中使用成员时,隐含了*this,f中的t::f()实际上是( *this ).t::f()。
class t{
public:
virtual void f(){}
};
class s:public t{
public:
void f(){t::f();}
};
int _tmain(int argc, _TCHAR* argv[])
{
t::f();
return 0;
}
------解决方案--------------------
因为在类成员函数中使用成员时,隐含了*this,f中的t::f()实际上是( *this ).t::f()。