H
Hongzheng Wang
Hi,
If I have such codes:
class fred {
//user defined constructors/destructor here
};
int main()
{
fred* p = &fred(); //(1)
//do something else...
return 0;
}
My compiler complained having assigned address of a temporal
object on line (1).
And I noticed that the fred's destructor is called immediatelly
after its constructor is called on line (1).
I'm wonder why a temporal object is created here.
Can anyone give some explanation?
Thank you very much.
If I have such codes:
class fred {
//user defined constructors/destructor here
};
int main()
{
fred* p = &fred(); //(1)
//do something else...
return 0;
}
My compiler complained having assigned address of a temporal
object on line (1).
And I noticed that the fred's destructor is called immediatelly
after its constructor is called on line (1).
I'm wonder why a temporal object is created here.
Can anyone give some explanation?
Thank you very much.