Reputation: 296
#include <iostream>
using namespace std;
class Obj {
public:
Obj(){cout <<"create obj" << endl;}
Obj(const Obj& other){cout<<"copy create obj"<<endl;}
~Obj(){cout<<"destructed obj"<<endl;}
};
int main() {
Obj(Obj((Obj())));
cout<<"---- exit main ----"<<endl;
}
I have no idea why this program only prints out 1 create obj and 1 destructed obj. Help.
Upvotes: 4
Views: 182