Advertisement
Guest User

xzcascs

a guest
Dec 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. class Figura
  6. {
  7.     char kolor;
  8.     public:
  9.     getKolor()
  10.         {
  11.             cout<<" kolor to : ";
  12.             cin>>kolor;
  13.             return kolor;
  14.         }
  15.     Figura(){};
  16. };
  17. class Kwadrat:public Figura
  18. {
  19.     int a;
  20.     public:
  21.         Kwadrat(int bok)
  22.         {
  23.             a=bok;
  24.         }
  25.     getPole()
  26.         {
  27.         double pole;
  28.         pole=a*a;
  29.         return pole;
  30.         }
  31. };
  32. class Prostokat:public Figura
  33. {
  34.     int a,b;
  35.     public:
  36.         Prostokat(int bok1, int bok2)
  37.         {
  38.             a=bok1;
  39.             b=bok2;
  40.         }
  41.     getPole()
  42.         {
  43.         double pole;
  44.         pole=a*b;
  45.         return pole;
  46.         }
  47. };
  48. int main()
  49. {
  50.     int x,y,z;
  51.     cout<<"podaj bok kwadratu: ";
  52.     cin>>x;
  53.     Kwadrat k(x);
  54.     cout<<"podaj boki prostokata: ";
  55.     cin>>y>>z;
  56.     Prostokat p(y,z);
  57.     cout<<"pole kwadratu to: "<<k.getPole()<<endl;
  58.     cout<<"pole prostokata to: "<<p.getPole();
  59.     cout<<p.getKolor();
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement