This question already has an answer here: What are the basic rules and idioms for operator overloading? 7 answers Let's suppose that we want to subtract some value from a given matrix. How could/should I overload that operator. main.cpp Matrix m(10, 5); auto r = 1.0 - m; //error: return type specified for 'operator double'  matrix.hpp template class Matrix { public: Matrix operator double(T val) { Matrix tmp(rows, cols); for (unsigned int i = 0; i < rows; i++) for (unsigned int j = 0; j < cols; j++) { const unsigned int idx = VecToIdx({i, j}); tmp[idx] = val - this[idx]; } return tmp; } }