Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Билет 1
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- class first
- {
- protected:
- double a;
- double b;
- public:
- first(double aa, double bb) :a(aa), b(bb) {}
- virtual double square(first&c)
- {
- return c.b*c.a;
- }
- ~first() { cout << "work1!" << endl; }
- };
- class second :public first
- {
- public:
- second(double aa, double bb) :first(aa, bb) {}
- double square(first&c) override
- {
- return 3.14*(c.a + c.b)*(c.a + c.b);
- }
- ~second() { cout << "work2!" << endl; };
- };
- int main()
- {
- first object1(5, 6);
- double s1, s2;
- s1 = square(object1);
- second object2(1, 1);
- s2 = square(object2);
- return 0;
- }
Add Comment
Please, Sign In to add comment