Hello (it's the newbie again).
If I have a class
class Foo{
public:
Foo(){cout<<"Making"<<endl;}
~Foo(){cout<<"Destroying"<<endl;}
};
void func(Foo x){}
int main(){
Foo a;
func(a);
}
I see three calls to the destructor. I assume these are,
the third = the destruction of object a in main
the second= the destruction of the object x in function "func"
the first = creation of a temporary copy of a, that is copied into x and
then destroyed?
I'm not sure about the first call to the destructor, is there a temp.
object created?
The first call to ~Foo is not there when I have a CC defined, and that's
because object x is created by the cc which in this case looks like
Foo(const Foo& cc){cout<<"CC"<<endl;}
But how is this any different from the default CC that is called in the
first case when I don't have any CC? (since I gues that the default CC
looks not too different from my CC, i.e. does nothing)
Can someone straighten this out for me?