Lacura
June 18th, 2002, 09:30 PM
As we all know, in C++, this means a pointer to
the object itself. But where and when is the pointer
created?
I have try the follwing cod:
class A{
A(){ cout<<"A::A() is called."; }
A(int a){ A(); cout<<"A:A(int a) is called"; };
~A(){ cout<<"A is destructing ...";}
}
main(){
A a;
return 0;
}
it shows that in the constructor A::A(int),
another tempory object of A is created.
Then the question is rasied:
Where and when is this be assigned,
at the beginning or at the end of the constructor?
the object itself. But where and when is the pointer
created?
I have try the follwing cod:
class A{
A(){ cout<<"A::A() is called."; }
A(int a){ A(); cout<<"A:A(int a) is called"; };
~A(){ cout<<"A is destructing ...";}
}
main(){
A a;
return 0;
}
it shows that in the constructor A::A(int),
another tempory object of A is created.
Then the question is rasied:
Where and when is this be assigned,
at the beginning or at the end of the constructor?