title: C++ object name same as class name
body: <p>I happen to write a code like this:</p>
  
  <pre><code>class a
  {
      public:
          a() {}
  };
  
  
  int main()
  {
      a *a = new a;        // line 10
      a a;                 // line 11
      return 0;
  }
  </code></pre>
  
  <p>g++ errors out:</p>
  
  <pre><code>2.c: In function ‘int main()’:
  2.c:10:16: error: expected type-specifier before ‘a’
  2.c:10:16: error: cannot convert ‘int*’ to ‘a*’ in initialization
  2.c:10:16: error: expected ‘,’ or ‘;’ before ‘a’
  2.c:11:7: error: expected ‘;’ before ‘a’
  </code></pre>
  
  <p>I found that, if I change "a *a" to "a *b" at line 10, then g++ is happy, here is the good code:</p>
  
  <pre><code>class a
  {
      public:
          a() {}
  };
  
  
  int main()
  {
      a *b = new a;
      a a;
      return 0;
  }
  </code></pre>
  
  <p>I am confused, not sure why the original code does not compile and how the "fix" works.</p>
  
  <p>Any idea?</p>