title: Runtime error in Visual Studio C++
body: <p>i have ran into an unknown problem in C++ when develping my small example with Visual Studio, and after debugging many times, i can't still find out what is  the problem here, please help me solve this:</p>
  
  <p>Here is my Header.h:</p>
  
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  using namespace std;
  </code></pre>
  
  <p>And here is my Team.h:</p>
  
  <pre><code>#pragma once
  #include "Header.h"
  class Driver;
  
  class Team
  {
  private:
      string quocGia;
      string ten;
      int soLanVoDich;
      vector&lt;Driver*&gt; ds_nguoi_dua;
  public:
      Team();
      Team(string quocGia, string ten, int soLanVD);
      ~Team(); 
      void AddRacer(Driver* myD);
  
      void AddRacer(string ten, string quocTich, int slThang, int slVD, Team* tenTeam);
      string getName();
  };
  </code></pre>
  
  <p>Now is the implementation for Team.h:</p>
  
  <pre><code>#include "Team.h"
  
  
  Team::Team()
  {
  }
  
  Team::Team(string ten, string quocGia, int soLanVD){
      this-&gt;quocGia = quocGia;
      this-&gt;ten = ten;
      this-&gt;soLanVoDich = soLanVD;
  }
  
  string Team::getName(){
      return this-&gt;ten;
  }
  
  
  Team::~Team()
  {
  }
  
  void Team::AddRacer(Driver* myD){
      this-&gt;ds_nguoi_dua.push_back(myD);
  }
  
  class Driver{
  public:
      Driver(string myTen, string quocTich, int slThang, int slVD, Team* tenTeam);
  };
  
  void Team::AddRacer(string myTen, string quocTich, int slThang, int slVD, Team* tenTeam){
      Driver* myD = new Driver(myTen, quocTich, slThang, slVD, this);
      this-&gt;ds_nguoi_dua.push_back(myD);
  }
  </code></pre>
  
  <p>Next, i define Driver class:</p>
  
  <pre><code>// Driver.h
  #pragma once
  #include "Header.h"
  
  class Team;
  
  class Driver
  {
  private:
      string hoTen;
      string quocTich;
      int soLanThang;
      int soLanVoDich;
      string tenTeam;
      static int diem;
  public:
      Driver();
  
      Driver(string hoTen, string quocTich, int soLanThang, int soLanVoDich, Team* tenTeam);
      ~Driver();
  };
  </code></pre>
  
  <p>And the implementation for that:</p>
  
  <pre><code>#include "Driver.h"
  
  int Driver::diem = 0;
  
  Driver::Driver()
  {
      this-&gt;hoTen = "";
      this-&gt;quocTich = "";
      this-&gt;soLanThang = 0;
      this-&gt;soLanVoDich = 0;
  }
  
  Driver::~Driver()
  {
  }
  
  class Team{
  public:
      string getName();
  };
  
  Driver::Driver(string mHoTen, string mQuocTich, int soLanThang, int slVD, Team* team){
      this-&gt;hoTen.assign(mHoTen);
      this-&gt;quocTich.assign(mQuocTich);
      this-&gt;soLanThang = soLanThang;
      this-&gt;soLanVoDich = slVD;
      this-&gt;tenTeam.assign(team-&gt;getName());
  }
  </code></pre>
  
  <p>I have a wrapper for Driver and Team:</p>
  
  <pre><code>#pragma once
  #include "Driver.h"
  #include "Team.h"
  #include &lt;algorithm&gt;
  
  using namespace std;
  
  class F1WorldFinal
  {
  public:
      F1WorldFinal();
      ~F1WorldFinal();
  };
  </code></pre>
  
  <p>And this is the main class:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include "F1WorldFinal.h"
  
  using namespace std;
  
  int main(){
      Team* teamRedBull = new Team("Red Bull", "Austrian", 4);
  
      Driver* driver = new Driver("David Coulthard", "British", 13, 0, teamRedBull);
  
      teamRedBull-&gt;AddRacer(driver);
  
      // The problem happens here.
      teamRedBull-&gt;AddRacer("Sebastian Vettel", "German", 42, 4, teamRedBull);
  
      return 0;
  }
  </code></pre>
  
  <p>But after changing the problem line into: </p>
  
  <pre><code>teamRedBull-&gt;AddRacer(new Driver("Sebastian Vettel", "German", 42, 4, teamRedBull));
  </code></pre>
  
  <p>Everything works well.</p>
  
  <p>Can you take time to explain me why this happened, i have debug and it turns out the problem is in xstring @@, so i really can't solve this.</p>