#include <vector>

template <typename T>
class matrix
{
    std::vector< std::vector<T> > data;
    size_t N, M;    
public:
        T& at(size_t x, size_t y);
        matrix<T> operator+(const matrix<T>& m2) const;
};

template<class T>
T& matrix<T>::at(size_t x, size_t y)
{ return data[x][y]; }

template<class T>
matrix<T> matrix<T>::operator+(const matrix<T>& m2) const
{    
    matrix<T> res;
    for(unsigned int i=0; i<N; ++i)
        for(unsigned int j=0; j<M; ++j)
            res.at(i,j) = this->at(i, j) + m2.at(i, j);    
    return res;
}

int main()
{
    matrix<int> a, b;
    a = a + b;
    return 0;
}