Here is the code, Code: class A { }; A foo(A a) { return a; } int main() { A a; foo(a); return 1; } As we know, two temporary variables will be generated. One is when a is passed to foo and another one is when foo returns a A object. But when exactly is destructor invoked for these two temporary variables?[/QUOTE]