Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Abstract
- {
- protected:
- double a;
- public:
- Abstract(const double& a):a(a) {}
- double GetA()const
- {
- return a;
- }
- void Sum(const Abstract &ab)
- {
- doSum(ab);
- }
- private:
- virtual void doSum(const Abstract &ab) = 0;
- };
- class Derived : public Abstract
- {
- public:
- Derived(const double& a) :Abstract(a) {}
- void doSum(const Abstract &der)
- {
- a += der.GetA();
- }
- };
- int main()
- {
- Derived object(2);
- Derived object2(5);
- object.Sum(object2);
- cout << object.GetA() << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement