#include <iostream>
using namespace std;
class Tester {
public:
Tester(int x);
~Tester();
int who;
} Tester_g_1(1) , Tester_g_2(2);
Tester::Tester(int id) {
cout << "Intializing" << id << endl ;
who = id;
}
Tester::~Tester() {
cout << "Destroying" << who << endl;
}
int main() {
Tester localObj(3);
cout << "This is not the first line to be displayed";
system("pause");
return 0;
}
我得到的输出是:
Intializing1
Intializing2
Intializing3
This is not the first line to be displayedPress any key to continue . . .
为什么析构函数中的语句不起作用? 使用情况: 编译器 - 微软Visual C++ 2010 Express 操作系统 - Win7