Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Punkt
- {
- private:
- int x,y;
- public:
- Punkt():x(0), y(0){}
- Punkt(int x, int y): x(x), y(y){}
- double odleglosc(const Punkt& a)const
- {
- return sqrt((x-a.x)*(x-a.x)+(y-a.y)*(x-a.y));
- }
- };
- class Wielobok
- {
- private:
- unsigned roz;
- Punkt *wsk;
- public:
- Wielobok():roz(0),wsk(0){}
- Wielobok(const Punkt * b,const Punkt *e):roz(e-b),
- wsk(roz ? new Punkt[roz]:0)
- {
- for(unsigned i=0;i<roz;++i)
- wsk[i] = b[i];
- }
- ~Wielobok(){delete[]wsk;}
- Wielobok (const Wielobok&);
- Wielobok& operator = (const Wielobok&);
- };
- int main()
- {
- punkt p(2, 3);
- cout << p.x() << ' ' << p.y() << '\n';
- p.x() = 1;
- p.y() = 1;
- cout << p.x() << ' ' << p.y() << '\n';
- cout << p.odleglosc(punkt()) << '\n';
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement