I created a class called Matrix with a 2D array. I can run it with the constructor, copy constructor and destructor. When I introduce the unary negation operator, I get a run time error.
https://gist.github.com/anonymous/7823794
#ifndef MATRIX_H
#define MATRIX_H
class Matrix
{
public:
    Matrix(int rSize=3, int cSize=3);
    Matrix(const Matrix& m);
    ~Matrix();
    bool setValue(int rSize, int cSize, int value);
    bool getValue(int rVal, int cVal, int& value)const;
    const Matrix operator- ();
private:
    int rowSize;
    int columnSize;
    int** arr;
};
#endif
#include<iostream>
#include"Matrix.h"
using namespace std;
Matrix::Matrix(int rSize,int cSize)
{
    columnSize = cSize;
    rowSize = rSize;
    arr = new int* [rowSize];
    for(int i=0; i<rowSize; i++)
        arr[i] = new int[columnSize];
    for(int j=0; j<rowSize; j++)
    {
        for(int k=0; k<columnSize; k++)
            arr[j][k] = 0;
    }
}
Matrix::Matrix(const Matrix& m)
{
    columnSize = m.columnSize;
    rowSize = m.rowSize;
    arr = new int* [rowSize];
    for(int i=0; i<rowSize; i++)
    {
        arr[i] = new int [columnSize];
    }
    for(int i=0; i<rowSize; i++)
    {
        for(int j=0; j<columnSize; j++)
            arr[i][j] = m.arr[i][j];
    }
}
Matrix::~Matrix()
{
    for(int i = 0; i < rowSize; ++i)
        delete [] arr[i];
    delete [] arr;
}
bool Matrix::setValue(int rVal, int cVal, int value)
{
    if((rVal<0)||(cVal<0)||(rVal>rowSize-1)||(cVal>columnSize-1))
        return false;
    arr[rVal][cVal] = value;
    return true;
}
bool Matrix::getValue(int rVal, int cVal, int& value)const
{
    if((rVal<0)||(cVal<0)||(rVal>rowSize-1)||(cVal>columnSize-1))
        return false;
    value = arr[rVal][cVal];
    return true;
}
const Matrix Matrix:: operator- ()
{
    Matrix m(*this);
    for (int i = 0; i< rowSize; i++)
    {
        for(int j=0; j<columnSize; j++)
            m.arr[i][j] = (this->arr[i][j])* -1 ;
    }
    return m;
}
#include<iostream>
#include"Matrix.h"
using namespace std;
void main()
{
    Matrix m(4, 5);
    Matrix m2(m);
    m2.setValue(1,2,12);
    int x;
    m2.getValue(1,2,x);
    Matrix m3;
    m3 = -m2;
}
Edit: Following @unwind and @interjay advice, I implemented the assignment operator first and returned a value, not a reference, for the negation operator and it works. Thank you all for your help
 
     
     
    