I recently have discovered the wonderful capability of C++ to allow programmers to overload operations on classes they create. As a way to venture into this topic, I decided to try making my own vector class.
As a little test to satisfy my curiousity, I recently did the following to overload the equality operators for my class:
95 bool Vect::operator==(const Vect& rhs){
96 return this->getCoord() == rhs.getCoord()
98 }
99
100 bool Vect::operator!=(const Vect& rhs){
101 return !(*this == rhs);
102 }
This compiles and works correctly. However, I had a question about whether or not this was good/bad practice (and why!). I do not want to fall into the habit of doing this if it's a bad one, or encourage myself to keep using this if its a good one.