main函数是C/C++中第一个被调用的函数吗?

#include <iostream>
class A {
public:
A() {
std::cout << "A constructor!" << std::endl;
}
~A() {
std::cout << "A destructor!" << std::endl;
}
};

/* 全局对象,在main函数之前,A的构造函数被调用 */
A a;

int main()
{
std::cout << "main begins" << std::endl;
return 0;
}

猜你喜欢

转载自www.cnblogs.com/ZhenXin0101/p/11451643.html