title: How to solve error (projectname has triggered breakpoint)?
body: <p>After I run the program I get an error saying projectname has triggered a breakpoint. I still do not know what the error is. I think there's a member function missing but someone help me out?</p>
  
  <pre><code>#include "AClass.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      AClass* x = new AClass(10, -1.0);
      AClass y = *x;
      delete x;
      return 0;
  }
  </code></pre>
  
  <p>Code from my cpp file is as follows:</p>
  
  <pre><code>#include "AClass.h"
  #include &lt;iostream&gt;
  using namespace std;
  
  // Constructor
  AClass::AClass(int len, double val)
      : length(len)
  {
      if (len &lt; 0) {
          cout &lt;&lt; "Invalid data length = " &lt;&lt; len &lt;&lt; endl;
          data = NULL;
      }
  
      else {
          data = new double[length];
          for (int i = 0; i &lt; length; i++)
              data[i] = val;
      }
  }
  
  // Destructor
  AClass::~AClass()
  {
      // delete data if it is not NULL
      if (data) delete[] data;
  }
  </code></pre>