写了个测试代码:
#include <iostream> using namespace std; class A { public: A(char i):m_i(i) { cout << m_i << "调用了构造函数"<<endl; } ~A() { cout << m_i << "调用了析构函数"<<endl; } private: char m_i; }; static A d('d'); int main() { A a('a'); static A b('b'); A c('c'); }
佳明的笔试上的,学习下吧!