Conditions for entering to destructor
<p>I have function I wrote in some class.
I don't understand why when I create object named: Square square; a d'tor of Square is being called when exiting the function.
While when I create the object as: Square* square = new Square(); no d'tor is being called.</p>

<p><strong>There is no inheritance at all on the classes</strong>.</p>

<p>Here an example for the function in a two versions:</p>

<pre><code>//=======Enter to d'tor in the end of the function to ~Square==========
void DrawShapesApp::addSquare()
{
    int row, col;
    int edge;
    char ch;

    Square square;

    getSquareInfo(row, col, edge, ch);
    square.setAll(row, col, edge, ch);
    m_squares.push_back(&amp;square);
}





//=======Doesn't enter to d'tor in the end of the function==========
void DrawShapesApp::addSquare()
{
    int row, col;
    int edge;
    char ch;
    Square* square = new Square();

    getSquareInfo(row, col, edge, ch);
        (*square).setAll(row, col, edge, ch);
    m_squares.push_back(&amp;square);
}
</code></pre>
