class A
{
public:
A(){ cout << "A.ctor()" << endl; }
// the others methods have similar couts
};
A f() { return A(); }
int main()
{
f();
}
When I run it, I see:
A.ctor()
A.dector()
which is fine with me.
But when I change the code to:
1 2 3 4
int main()
{
A a = f();
}
I see the same output o.O
Why is the copy constructor of A never called, and which dector do I call in the end - the one of the temporary object, or the the one of the variable 'a'?