#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;
}
原文地址:https://www.cnblogs.com/ZhenXin0101/p/11451643.html
时间: 2024-11-09 01:47:40