#include <iostream>
using namespace std;
class Test
{
public:
Test()
{
printf("construct ..
");
}
~Test()
{
printf("destruct...
");
}
};
Test Get()
{
Test t = Test();
return t;
}
int main(int argc, char *argv[])
{
Test t = Get();
return 0;
}
the console output is :
$ g++ -g -Wall -O0 testdestructor.cc
$ ./a.out
construct ..
destruct...
See Question&Answers more detail:os