Untitled
unknown
c_cpp
2 months ago
1.1 kB
1
Indexable
Never
#include <iostream> using namespace std; class Coord { private: int x, y; public: MyInt( const int val = 0 ) : value( val ) int GetX() const { return x; } int GetY() const { return y; } void SetX( const int x ){ this->x = x; } void SetY( const int y ){ this->y = y; } MyInt operator+( const MyInt& other ); MyInt operator-( const MyInt& other ); MyInt operator*( const MyInt& other ); MyInt operator/( const MyInt& other ); MyInt& operator+=( const MyInt& other ); MyInt& operator-=( const MyInt& other ); MyInt& operator*=( const MyInt& other ); MyInt& operator/=( const MyInt& other ); }; int main() { // constructor Coord a( 3, 4 ), b( 5, 6 ); Coord c = a + b; // 8, 10 copy constructor c = a - b; // -2, -2 operator= cout << "Hello world!" << endl; /*operator== operator!= operator+ operator- operator+= operator-= */ return 0; }