Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Punkt
- {
- string nazwa;
- float x,y;
- public:
- void wczytaj()
- {
- cout<<nazwa<<"("<<x<<","<<y<<")"<<endl;
- }
- Punkt(string n="S", float xx=1, float yy=1)
- {
- nazwa=n;
- x=xx;
- y=yy;
- }
- };
- class Kolo :public Punkt //klasa Kolo dziedziczy publicznie z klasy punkt
- {
- string nazwa;
- protected:
- float r;
- public:
- void wczytaj()
- {
- cout<<"Kolo o nazwie: "<<nazwa<<endl;
- cout<<"Srodek kola: ";
- Punkt::wczytaj();
- cout<<endl<<"Promien kola: "<<r<<endl;
- cout<<"Pole kola :"<<M_PI*r*r<<endl;
- }
- Kolo(string nk="kolko", string np="S", float a=1, float b=1, float pr=3)
- :Punkt(np,a,b)
- {
- nazwa = nk;
- r = pr;
- }
- };
- class Kula :public Kolo
- {
- string nazwa;
- public:
- void wczytaj()
- {
- cout<<"Kula o nazwie: "<<nazwa<<endl;
- cout<<"Srodek kuli: ";
- Kolo::wczytaj();
- cout<<endl<<"Promien kuli: "<<r<<endl;
- cout<<"Objetosc kuli: "<<(4.0/3.0)*M_PI*r*r*r;
- }
- Kula(string nazwakola="kolko", string nazwapunkt="punkt", float aa=5, float bb=5, float prr=1, string nkula="kula", float rkula=1)
- :Kolo(nazwakola,nazwapunkt,aa,bb,prr)
- {
- nazwa=nkula;
- r=rkula;
- }
- };
- int main()
- {
- Kula k1;
- k1.wczytaj();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement