title: Creating new instance of class on stack with no empty no arguments constructor
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/5385675/calling-the-default-constuctor">Calling the default constuctor</a><br>
    <a href="https://stackoverflow.com/questions/180172/why-is-it-an-error-to-use-an-empty-set-of-brackets-to-call-a-constructor-with-no">Why is it an error to use an empty set of brackets to call a constructor with no arguments?</a>  </p>
  </blockquote>
  
  
  
  <p>I am wondering what it means to create an instance of a class using a no arguments constructor.</p>
  
  <p>For example if I have a class "A" and try to create a variable like so:</p>
  
  <pre><code>A myVariable()
  </code></pre>
  
  <p>I tried to put together a little project to test it:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class A
  {
      public:
          A();
          A( int a, int b );
      public:
          int mA;
          int mB;
      private:
          virtual void init( int a , int b );
  };
  
  A::A()
  {
      cout &lt;&lt; "\tA()" &lt;&lt; endl;
      this-&gt;init( 0, 0 );
  } // end of function A::A
  
  A::A( int a, int b = 0 )
  {
      cout &lt;&lt; "\tA( int a, int b )" &lt;&lt; endl;
      this-&gt;init( a, b );
  } // end of function A::A
  
  void A::init( int a, int b )
  {
      cout &lt;&lt; "\tInit( int a, int b )" &lt;&lt; endl;
      mA = a;
      mB = b;
  } // end of function A::init
  
  int main()
  {
  cout &lt;&lt; "Start" &lt;&lt; endl;
      cout &lt;&lt; "A myA0()" &lt;&lt; endl;
      A myA0();
  
      cout &lt;&lt; "A myA1" &lt;&lt; endl;
      A myA1;
  
      cout &lt;&lt; "A myA2( 0 )" &lt;&lt; endl;
      A myA2( 0 );
  
      cout &lt;&lt; "A myA3( 0, 0 )" &lt;&lt; endl;
      A myA3( 0, 0 );
  
      cout &lt;&lt; "Stop" &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>The output looks like this:</p>
  
  <pre><code>Start
  A myA0()
  A myA1
      A()
      Init( int a, int b )
  A myA2( 0 )
      A( int a, int b )
      Init( int a, int b )
  A myA3( 0, 0 )
      A( int a, int b )
      Init( int a, int b )
  Stop
  </code></pre>
  
  <p>So it doesn't seem to call any constructor. When I try to step through it in Visual Studio it just skips over it like it wasn't compiled and when I try to print out the variable i get an unknown extern symbol error.</p>
  
  <p>Note: Of course when using the new operator doing "new A()" is required and will use the default constructor.</p>