Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Punkt
- {
- //protected:
- float x, y;
- public:
- Punkt(float xx=0, float yy=0)
- {
- x=xx;
- y=yy;
- }
- void Wyslietl()
- {
- cout<<x<<endl<<y<<endl;
- }
- };
- class Kolo:public Punkt
- {
- protected:
- int r;
- int p;
- public:
- Kolo(float xx=0, float yy=0, float rr=1)
- :Punkt(xx, yy)
- {
- //x=xx;
- //y=yy;
- r=rr;
- p=M_PI*r*r;
- }
- float pole()
- {
- int p;
- p=M_PI*r*r;
- return p;
- }
- void Wyslietl()
- {
- Punkt::Wyslietl();
- cout<<r<<endl;
- cout<<p<<endl;
- }
- };
- class Kula: public Kolo
- {
- //int p;
- float v;
- public:
- Kula(float xx=0, float yy=0, float rr=1)
- :Kolo(xx, yy, rr)
- {
- //x=xx;
- //y=yy;
- //r=rr;
- p=4*M_PI*r*r;
- v=(4/3)*M_PI*r*r*r;
- }
- /*float pole()
- {
- int p;
- p=4*M_PI*M_PI;
- return p;
- }*/
- void Wyslietl()
- {
- Kolo::Wyslietl();
- cout<<v;
- }
- };
- int main()
- {
- /*cout << "Hello world!" << endl;
- Punkt p1;
- p1.Wyslietl();
- Kolo k1;
- cout<<k1.pole()<<endl;
- k1.Wyslietl();*/
- Kula k2(float=1, float=2, float=3);
- k2.Wyslietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement