Facebook
From McHalt, 5 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 277
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. class Punkt{
  6. private:
  7.     int x, y;
  8. public:
  9.     Punkt(int x, int y){
  10.         this->x = x;
  11.         this->y = y;
  12.     }
  13.     friend ostream& operator<<(ostream& oo, Punkt& pp);
  14.     friend istream& operator>>(istream& oo, Punkt& pp);
  15. };
  16.  
  17. ostream& operator<<(ostream& oo, Punkt& pp){
  18.     oo << "{" << pp.x << ", " << pp.y << "}\n";
  19.     return oo;
  20. }
  21.  
  22. istream& operator>>(istream& oo, Punkt& pp){
  23.     oo >> pp.x;
  24.     oo >> pp.y;
  25.     return oo;
  26. }
  27.  
  28. int main(){
  29.     Punkt p(1,2);
  30.     cin >> p;
  31.     cout << p;
  32.     return 0;
  33. }

Replies to laby rss

Title Name Language When
Re: laby McHalt cpp 5 Years ago.