【发布时间】:2014-06-16 16:53:08
【问题描述】:
我正在做一个项目,我遇到了一些奇怪的代码,我无法理解为什么会发生这种情况以及如何发生!
我有一个类 Foo 和 Baz,而 Foo 有一个从 Baz 类调用而不实例化 Foo 的非静态方法:
class Foo {
public:
void qux(int a, int b);
};
class Baz {
public:
void bar(void);
};
void Baz::bar(void){
Foo::qux(2,3); // This should not happen as qux is not a static method !!
}
【问题讨论】:
-
您确定这是实际代码吗?也许 baz 继承自 foo?