Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Билет 14
- #include <iostream>
- using namespace std;
- template<typename T>
- T count(T x)
- {
- return 3,14*x*x;
- }
- class circle
- {
- protected:
- double r;
- public:
- circle(double rad):r(rad)
- {
- cout << "RADIUS = " << r << endl;
- cout << "Work!" << endl;
- }
- ~circle() {
- cout << "Destructor!" << endl;
- }
- };
- class square: public circle
- {
- private:
- double s;
- public:
- square(double rad):circle(rad)
- {
- s = 0;
- cout << "Work1!" << endl;
- }
- double count(double r)
- {
- return s = 3.14*r*r;
- }
- void show()
- {
- if (s == 0) count(r);
- cout << "SQUARE = " << s << endl;
- }
- ~square()
- {
- cout << "Destructor1!" << endl;
- }
- };
- int main()
- {
- circle a(5);
- square b(5);
- b.show();
- return 0;
- }
Add Comment
Please, Sign In to add comment