title: C++ Object Undeclared Identifier
body: <p>I'm no newbie to code, but I am to Visual Studios. For the life of me, I cannot figure out why I am getting the following syntax errors. The code is refusing to allow me to declare an object <code>Match m = new Match();</code>.</p>
  
  <p><strong>Main.cpp</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;time.h&gt;
  #include "Match.h"
  #include "stdafx.h"
  
  using namespace std;
  
  const int NUM_TRIALS = 100000;
  
  int main()
  {
      Match m = new Match();
      printf("Program begin\n");
      for (int i = 0; i &lt; 200; i++) {
          m = Match();
          printf("%s ... %s\n", m.to_str123().c_str(), m.printStr.c_str());
      }
      printf("Program end.\n");
      return 0;
  }
  </code></pre>
  
  <p><strong>Match.h</strong></p>
  
  <pre><code>#pragma once
  #ifndef MATCH_H_
  #define MATCH_H_
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;time.h&gt;
  
  using namespace std;
  
  #define HERO_PER_TEAM 3
  #define NUM_HERO 10
  
  class Match {
  public:
      Match();
      ~Match();
  
      string to_str123();
      string printStr();
  
  private:
      char teams[HERO_PER_TEAM * 2];
  };
  
  #endif
  </code></pre>
  
  <p><strong>Error Messages</strong></p>
  
  <pre><code>Error   C2065   'Match': undeclared identifier  ConsoleApplication1 
  Error   C2146   syntax error: missing ';' before identifier 'm' ConsoleApplication1 
  Error   C2065   'm': undeclared identifier  ConsoleApplication1 
  Error   C2061   syntax error: identifier 'Match'    ConsoleApplication1
  Error   C2065   'm': undeclared identifier  ConsoleApplication1 
  Error   C3861   'Match': identifier not found   ConsoleApplication1 
  Error   C2065   'm': undeclared identifier  ConsoleApplication1 
  Error   C2228   left of '.to_str123' must have class/struct/union   ConsoleApplication1 
  Error   C2228   left of '.c_str' must have class/struct/union   ConsoleApplication1 
  Error   C2228   left of '.printStr' must have class/struct/union    ConsoleApplication1
  </code></pre>