Calling the destructor of derived class
<p>Why was destructor of Derived class called in this code?</p>

<pre><code>#include &lt;iostream&gt;

class Base
{
public:
   Base() { std::cout &lt;&lt; "Base::Base() \n"; }
   ~Base() { std::cout &lt;&lt; "Base::~Base() \n"; } 
};

class Derived : public Base
{
public:
   Derived() { std::cout &lt;&lt; "Derived::Derived() \n"; }
   ~Derived() { std::cout &lt;&lt; "Derived::~Derived() \n"; } 
};

Derived foo() { return Derived(); }

int main()
{
   const Derived&amp; instance = foo();
}
</code></pre>
