是否可以在静态成员函数中调用非静态数据成员? 是否也可以在静态成员函数中调用非静态成员函数?
你是怎么做到的?
最佳答案
是的 - 你可以,这就是方法
class Foo
{
public:
static void staticFunc( const Foo & foo)
{
foo.memberFunc();
}
void memberFunc() const
{
staticFunc(*this);
}
};
这是一种设计,除了递归之外,演示了如何调用静态和非静态成员函数。
关于c++ - 非静态和静态数据和函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/631610/