What is the lifetime of unnamed object of a class ?
Helo all :)
Say i have a class
and two functions f and g
Code:
void f()
{
A();
return calculateSomething();
}
void g()
{
A obj;
return calculateSomething();
}
The differences between f and g appear to be the fact that unnamed object of class A in f is destroyed before calculateSomething is even called - you can say it lives only in that single line ( A(); )
The object named 'obj' rather lives until the function returns, which is of course understood.
THis is compiled under VC++ 7.0.
Is it right about the lifetime of unnamed object of class A ? Shouldnt their lifetimes be the same ?