temp.x = x + op2.x; // These are integer additions temp.y = y + op2.y; // and the + retains is original temp.z = z + op2.z; // meaning relative to them. return temp; }
// Overload assignment. MyClass MyClass::operator=(MyClass op2) { x = op2.x; // These are integer assignments y = op2.y; // and the = retains its original z = op2.z; // meaning relative to them. return *this; }
// Overload the prefix version of ++. MyClass MyClass::operator++() { x++; // increment x, y, and z y++; z++; return *this; }
// Show X, Y, Z coordinates. void MyClass::show() { cout << x << ", "; cout << y << ", "; cout << z << endl; }