hac*_*ock 1 c++ visual-studio-2008 visual-c++
#include <iostream>
using namespace std;
class test{
public:
test() { cout<<"CTOR"<<endl; }
~test() { cout<<"DTOR"<<endl; }
};
int main()
{
test testObj();
cout<<"HERE"<<endl;
}
Run Code Online (Sandbox Code Playgroud)
输出:
HERE
Run Code Online (Sandbox Code Playgroud)
编译器跳过"test testObj();"行并用警告编译其余部分,并在运行时生成输出.警告是"VC++ 2008中没有调用原型函数(是一个变量定义?).为什么不抛出错误?