axeefectushka

Untitled

Jan 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. Билет 14
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. template<typename T>
  6. T count(T x)
  7. {
  8.     return 3,14*x*x;
  9. }
  10. class circle
  11. {
  12. protected:
  13.     double r;
  14. public:
  15.     circle(double rad):r(rad)
  16.     {
  17.         cout << "RADIUS = " << r << endl;
  18.         cout << "Work!" << endl;
  19.     }
  20.     ~circle() {
  21.         cout << "Destructor!" << endl;
  22.     }
  23. };
  24.  
  25. class square: public circle
  26. {
  27. private:
  28.     double s;
  29. public:
  30.     square(double rad):circle(rad)
  31.     {
  32.         s = 0;
  33.         cout << "Work1!" << endl;
  34.     }
  35.     double count(double r)
  36.     {
  37.         return s = 3.14*r*r;
  38.     }
  39.     void show()
  40.     {
  41.         if (s == 0) count(r);
  42.         cout << "SQUARE = " << s << endl;
  43.  
  44.     }
  45.     ~square()
  46.     {
  47.         cout << "Destructor1!" << endl;
  48.     }
  49. };
  50.  
  51.  
  52. int main()
  53. {
  54.     circle a(5);
  55.     square b(5);
  56.     b.show();
  57.     return 0;
  58. }
Add Comment
Please, Sign In to add comment