fork download
  1. #include <iostream>
  2.  
  3. class Matrix
  4. {
  5. int rows;
  6. int cols;
  7. short int** value_array;
  8. public:
  9. Matrix(unsigned int x, unsigned int y);
  10. ~Matrix();
  11. };
  12.  
  13. Matrix::Matrix(unsigned int x, unsigned int y)
  14. {
  15. rows = x;
  16. cols = y;
  17. value_array = NULL;
  18. value_array = new short int*[rows];
  19. for (unsigned int i = 0; i < cols; i++)
  20. value_array[i] = new short int[cols];
  21. }
  22.  
  23. Matrix::~Matrix()
  24. {
  25. for (unsigned int i = 0; i < rows; i++)
  26. delete [] value_array[i];
  27. delete [] value_array;
  28. }
  29.  
  30. using namespace std;
  31.  
  32. int main()
  33. {
  34. Matrix m(10,20);
  35. }
Runtime error #stdin #stdout #stderr 0s 3460KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
*** Error in `./prog': double free or corruption (out): 0x0831ea40 ***