Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Figura
- {
- char kolor;
- public:
- getKolor()
- {
- cout<<" kolor to : ";
- cin>>kolor;
- return kolor;
- }
- Figura(){};
- };
- class Kwadrat:public Figura
- {
- int a;
- public:
- Kwadrat(int bok)
- {
- a=bok;
- }
- getPole()
- {
- double pole;
- pole=a*a;
- return pole;
- }
- };
- class Prostokat:public Figura
- {
- int a,b;
- public:
- Prostokat(int bok1, int bok2)
- {
- a=bok1;
- b=bok2;
- }
- getPole()
- {
- double pole;
- pole=a*b;
- return pole;
- }
- };
- int main()
- {
- int x,y,z;
- cout<<"podaj bok kwadratu: ";
- cin>>x;
- Kwadrat k(x);
- cout<<"podaj boki prostokata: ";
- cin>>y>>z;
- Prostokat p(y,z);
- cout<<"pole kwadratu to: "<<k.getPole()<<endl;
- cout<<"pole prostokata to: "<<p.getPole();
- cout<<p.getKolor();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement