Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class punkt
- {
- public:
- int x,y;
- punkt(int wartosc_x, int wartosc_y):x(wartosc_x),y(wartosc_y)
- {
- }
- friend punkt operator+(const punkt& pkt1, const punkt& pkt2);
- friend ostream& operator<<(ostream& out, punkt& pkt);
- };
- punkt operator+(const punkt& pkt1, const punkt& pkt2)
- {
- return punkt(pkt1.x+pkt2.x, pkt1.y+pkt2.y);
- }
- ostream& operator<<(ostream& out, punkt& pkt)
- {
- out<<"("<<pkt.x<<", "<<pkt.y<<")";
- return out;
- }
- int main()
- {
- punkt poczatek(1,1), koniec(6,6);
- punkt suma = poczatek + koniec;
- cout<< suma<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement