Dvortsov_D1

классы , площадь фигур

Mar 6th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class shaid{
  5. public:
  6.     virtual void print()=0;
  7.  
  8.  };
  9.  
  10.  class trriangle : public shaid{
  11.  public:
  12.     int a;
  13.     int h;
  14.     void print(){
  15.         int S= (a*h)*0.5;
  16.         cout <<  S << endl;
  17.     }
  18.  };
  19.  class rectangl : public shaid{
  20.  public:
  21.     int a;
  22.     int b;
  23.     void print(){
  24.         int S= a*b;
  25.         cout <<  S << endl;
  26.     }
  27.  };
  28.  class circle  : public shaid{
  29.  public:
  30.     int r;
  31.     int pi;
  32.     void print(){
  33.         int S= pi*(r*r*r);
  34.         cout <<  S << endl;
  35.     }
  36.  };
  37.  
  38. int main()
  39. {
  40. /*
  41.    triangl d = dog();
  42.    restangle c = cat();
  43.    d.print();
  44.    c.print();
  45.  
  46.    dog*a     = new dog();
  47.    cat*b  = new cat();
  48.  
  49.    a->print();
  50.    (*b).print();
  51.  
  52.    animal*df = new animal();
  53.    df->print();
  54.    animal*cl = new cat();
  55.    cl->print();
  56. */
  57.   shaid*hg =new trriangle();
  58.   hg->print();
  59.   shaid*ab = new rectangl();
  60.   ab->print();
  61.   shaid*uf = new  circle();
  62.   uf->print();
  63. }
Advertisement
Add Comment
Please, Sign In to add comment