title: Keep getting a Debug Assertion Failed! Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
body: <p>I've been searching this problem for a couple days now and nothing I try seems to work. I'm getting it when my program ends, otherwise the program runs just fine so I "think" it has something to do with the Destructor. But I've tried looping through arrPtr and deleting all the elements first and it doesn't fix it. I'm using Visual Studio.</p>
  
  <p>I'm just including a partial of my code. Basically the ComputerPlayer::computer takes in a 2D array that is declared and initialized in main. It then assigns it to an allocated array so that the rest of the Class functions can look at it and decide which element to change. Once it decides it makes a change to the allocated array pointer which changes the original array element in main.</p>
  
  <p>I was hoping thinking the Destructor would "unallocate" the array once the program ended as I can't see where else to do it.</p>
  
  <p>Thanks,
  Mike</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  
  using namespace std;
  
  class ComputerPlayer
  {
  
      private:
      static const int ROWS = 3;     // holds # of array rows.
      static const int COLS = 3;     // Sets # of array columns.
      char(*arrPtr)[COLS] = new char[ROWS][COLS]; // Dynamically allocate 2D array
  
      bool isBlockOrWin();
      void blockChoiceRow(int, int);
      void blockChoiceCol(int, int);
      void blockChoiceDiag(char);
      void randomSelect();
      void sendArrMod(int, int);
  
      public:
      ComputerPlayer();
      ~ComputerPlayer();
      void computer(char(&amp;)[ROWS][COLS]);
  
  };
  
  ComputerPlayer::ComputerPlayer()
  {}
  
  ComputerPlayer::~ComputerPlayer()
  {
      delete[] arrPtr;
  }
  
  void ComputerPlayer::computer(char (&amp;temp)[ROWS][COLS])
  {
      // Assign the argument to the dynamically allocated array pointer.
      arrPtr = temp;
  
      if (isBlockOrWin())
      { }
      else randomSelect();
  }
  
  void ComputerPlayer::sendArrMod(int r, int c)
  {
      cout &lt;&lt; "The Computer 'c' selects: " &lt;&lt; r + 1 &lt;&lt; " " &lt;&lt; c + 1 &lt;&lt; endl;
  
      arrPtr[r][c] = 'c'; //Modify the array in main with the computers choice.
  }
  </code></pre>