logo       

Re: Order of Object destruction: msg#00208

gcc.help

Subject: Re: Order of Object destruction

Hi Neophytos,

>When the call foo(a) is made the copy constructor is called and makes a new object "z". This object "z" is supposed to be desposed off when it goes out of scope.

Correct. And it does. Temporary object "z" goes out of scope at the caller's semi-colon.

Returned object "b" also goes out of scope at the caller's semi-colon.

>I was asking which was supposed to be desposed of first "z" or "b"?

I think it is up to the discretion of the compiler's vendor whether it's a LIFO object destruction at the semi-colon, or FIFO object destruction.

Sincerely,
--Eljay




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise