title: Creating a class object in c++
body: <p>First i am from JAVA.</p>
  <p>In java we create class object like this.</p>
  <pre><code>Example example=new Example();
  </code></pre>
  <p>The Example class can have constructor or cannot have constructor.</p>
  <p>I can use the same in c++ like this</p>
  <pre><code>Example* example=new Example();
  </code></pre>
  <p>Where constructor is compulsory.</p>
  <p>From this tutorial <a href="http://www.cplusplus.com/doc/tutorial/classes/" rel="noreferrer">http://www.cplusplus.com/doc/tutorial/classes/</a></p>
  <p>I got that we can create object like this.</p>
  <pre><code>Example example;
  </code></pre>
  <p>Which do not require an constructor.</p>
  <p>I have two questions.</p>
  <ol>
  <li><p>What is the difference between both the way of creating class objects.</p>
  </li>
  <li><p>If I am creating object like <code>Example example;</code> how to use that in an singleton class.</p>
  </li>
  </ol>
  <p>like I usually do like this.</p>
  <pre><code>Sample* Singleton::get_sample() {
      if (sample == NULL) {
          sample = new Sample();
      }
      return sample;
  }
  </code></pre>
  <p>Please guide me if I am wrong.</p>