Operator Overloading: Member vs Non-Member
You're overloading operator+ for a Matrix class to support expressions like m1 + m2. Which signature is preferred and why?
// Option A: member function
Matrix Matrix::operator+(const Matrix& rhs) const;
// Option B: non-member function
Matrix operator+(const Matrix& lhs, const Matrix& rhs);
Sign in to answer questions and track your progress
Sign In