When is Destructor Called for temporary variables?

Discussion in 'C++' started by LarryChen, Jul 7, 2010.

  1. LarryChen

    LarryChen New Member

    Joined:
    Jun 23, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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]
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice