Always creating instance of class?
<p>I have a class that has only one function "Print()" and two properties "age, sex". And i am trying to understand when is object creating on memory? </p>

<p>i can always access to object's props and functions even i didn't call it's constructor function. </p>

<p>Isn't there any rule for the creating object from the class?</p>

<p>In C# this won't create object on memory: <code>ClassName cls;</code>
But this will create: <code>ClassName cls = new ClassName();</code>
<strong>In C++ is there any way to not create object in memory until i need to call it's constructor function?</strong></p>

<pre><code>#include &lt;QtCore/QCoreApplication&gt;
#include "iostream"

using namespace std;

class ClassName{
public:
    void print(){
        cout&lt;&lt; "Age: " &lt;&lt;age &lt;&lt;endl;
        cout&lt;&lt; "Sex: " &lt;&lt;sex &lt;&lt;endl;
    }
    int age;
    char sex;


};


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    ClassName *ex1 = new ClassName();
    ex1-&gt;print();

    ClassName ex2;
    ex2.print();

    ClassName ex3= {10,'e'};
    ex3.print();

    ClassName exCopy(ex3);
    exCopy.print();

    return a.exec();
}
</code></pre>
