Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- /*extern void oblicz_objętość(Kwadrat a)
- {
- a.objętość = a.bok*a.bok*a.bok;
- }*/
- class Figura
- {
- public:
- string nazwa;
- void wyswietl_dane();
- Figura(string a = "Figura");
- };
- class Kwadrat: public Figura
- {
- private:
- int bok, pole, objętość;
- public:
- Kwadrat(string a = "Figura", int b = 1);
- void wyswietl_dane();
- protected:
- void oblicz_pole();
- };
- Figura::Figura(string a)
- {
- nazwa = a;
- }
- Kwadrat::Kwadrat(string a, int b) :Figura(a)
- {
- bok = b;
- oblicz_pole();
- }
- void Figura::wyswietl_dane()
- {
- cout << nazwa << endl;
- }
- void Kwadrat::wyswietl_dane()
- {
- cout << nazwa << " i jego wlasciwosci" << endl;
- cout << "Pole: " << pole << endl;
- cout << "Objetosc: " << objętość << endl;
- }
- void Kwadrat::oblicz_pole()
- {
- pole = bok*bok;
- }
- int main()
- {
- Kwadrat k("Kwadrat", 4);
- Kwadrat k2;
- //oblicz_objętość(k);
- //oblicz_objętość(k2);
- k.wyswietl_dane();
- k2.wyswietl_dane();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement