【发布时间】:2011-09-19 07:26:29
【问题描述】:
#include <iostream>
using namespace std;
class Test
{
public:
Test()
{
printf("construct ..\n");
}
~Test()
{
printf("destruct...\n");
}
};
Test Get()
{
Test t = Test();
return t;
}
int main(int argc, char *argv[])
{
Test t = Get();
return 0;
}
控制台输出是:
$ g++ -g -Wall -O0 testdestructor.cc
$ ./a.out
构造..
破坏...
【问题讨论】:
标签: c++ destructor