title: Constructor and Variable Declaration in Cpp
body: <pre><code>#include&lt;bits/stdc++.h&gt;
  using namespace std;
  
  class A{
      int x;
  
  public:
      A(){
          x=10;
      }
  
      void show(){
          cout&lt;&lt;x&lt;&lt;endl;
      }
  };
  
  main(){
  
      A a;
      a.show();
  
  }
  </code></pre>
  
  <p>In the <code>main()</code> function when I am declaring the variable <code>a</code> in the above way, the code works fine but if we declare the variable <code>A a()</code> compiler gives error. Why is it so? I think there is no problem regarding argument type matching. Can anyone help?</p>