Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class figura
- {
- public:
- string nazwa;
- double pole();
- double obwod();
- };
- double figura::pole()
- {
- cout << "Pole figury " << endl;
- return 0;
- }
- double figura::obwod()
- {
- cout << "Obwod figury " << endl;
- return 0;
- }
- class prostokat : public figura
- {
- public:
- double podstawa;
- double wysokosc;
- double pole();
- double obwod();
- };
- double prostokat::pole()
- {
- double pole_p;
- cout << "Pole prostokata: ";
- pole_p = podstawa * wysokosc;
- return pole_p;
- }
- double prostokat::obwod()
- {
- double obwod_p;
- cout << "Obwod prostokata: ";
- obwod_p = 2*(podstawa + wysokosc);
- return obwod_p;
- }
- class trojkat : public figura
- {
- public:
- double podstawa;
- double wysokosc;
- double pole();
- };
- double trojkat::pole()
- {
- double pole_t;
- cout << "Pole trojkata: ";
- pole_t = (podstawa * wysokosc)/2;
- return pole_t;
- }
- int main()
- {
- figura f;
- f.pole();
- f.obwod();
- prostokat p;
- prostokat * ptr_p = & p;
- p.podstawa = 10;
- p.wysokosc = 5;
- trojkat t;
- trojkat * ptr_t = & t;
- t.podstawa = 5;
- t.wysokosc = 15;
- cout << p.pole() << endl;
- cout << p.obwod() << endl;
- cout << "Wskaznik" << endl;
- cout << ptr_p->pole() << endl;
- cout << t.pole() << endl;
- cout << "Wskaznik" << endl;
- cout << ptr_t->pole() << endl;
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement