例如:
class B;
class A {
public:
B f();
};
int main(int, char**) {
A a; // no exception and error
return 0;
}
Run Code Online (Sandbox Code Playgroud)
该类A
可能是不完整的类型。
为什么A
这个例子中可以实例化类呢?
f
我知道当代码中调用成员函数时,程序将无法编译。
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
// write code here
printf("%d\n", a);
return EXIT_SUCCESS;
}
static int a = 10;
Run Code Online (Sandbox Code Playgroud)
如何a
在注释位置引用静态全局变量?
我知道a
main 之前的那个地方不会导致这个问题。我只想知道是否有任何相关的语法可以做到这一点?