Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- #include <math.h>
- using namespace std;
- class punkt
- {
- public:
- punkt();
- punkt(int a,int b);
- int getx();
- void setx(int x);
- int gety();
- void sety(int y);
- void operator~(); //wypisz
- protected:
- int x;
- int y;
- };
- punkt::punkt()
- {
- x=0;
- y=0;
- }
- punkt::punkt(int a,int b)
- {
- x=a;
- y=b;
- }
- int punkt::getx()
- {
- return x;
- }
- int punkt::gety()
- {
- return y;
- }
- void punkt::setx(int a)
- {
- x=a;
- }
- void punkt::sety(int a)
- {
- y=a;
- }
- void punkt::operator~()
- {
- cout<<"Punkt: ("<<x<<","<<y<<")"<<endl;
- }
- class pixel:public punkt
- {
- public:
- pixel(int x,int y,int c);
- int getk();
- void setk(int c);
- void operator~();
- float oblicz(pixel &p);
- protected:
- int kolor;
- };
- pixel::pixel(int x,int y,int c) : punkt(x,y)
- {
- kolor=c;
- }
- int pixel::getk()
- {
- return kolor;
- }
- void pixel::setk(int c)
- {
- kolor=c;
- }
- void pixel::operator~()
- {
- cout<<"X= "<<x<<" Y= "<<y<<" Kolor: "<<kolor<<endl;
- }
- float pixel::oblicz(pixel &p)
- {
- return sqrt(pow((x-p.x),2)+pow((y-p.y),2));
- }
- int main(){
- punkt P1(1,2);
- ~P1;
- pixel P11(6,5,5);
- pixel P12(7,13,2);
- ~P11;
- ~P12;
- cout<<"Odleglosc miedzy punktami: "<<P11.oblicz(P12)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement