<< and >> operator overloading in c++ code example
Example 1: operator overloading in c++ <<
ostream &operator<<(ostream &output, const MyClass &myObject)
{
output << "P : " << myObject.property;
return output;
}
Example 2: c++ over load operator
// This will substract one vector (math vector) from another
// Good example of how to use operator overloading
vec2 operator - (vec2 const &other) {
return vec2(x - other.x, y - other.y);
}