vc++开发的程序,程序在调试时总是从main函数开始,这就让很多开发者认为main函数就是应用程序的入口.其实不然,在main函数执行之前,编译器已经为我们干了很多事!
一个小例子即可说明:
#include<iostream>
using namespace std;
void start()
{
cout<<"front of the main"<<endl;
}
class Test
{
public:
Test(int val = 0):value(val)
{
start();
}
~Test(){}
private:
int value;
};
Test a;
int main(void)
{
cout<<"main is over"<<endl;
return 0;
}
运行结果:
front of the main
main is over