Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class ICalculator
- {
- public:
- virtual int calculate(int x,int y) = 0;
- };
- class Adder : public ICalculator
- {
- public:
- int Calculate(int x,int y)
- {
- int s;
- s=x+y;
- return s;
- }
- };
- class Multiplier : public ICalculator
- {
- public:
- int Calculate(int x, int y)
- {
- int m;
- m=x*y;
- return m;
- }
- };
- class Problem
- {
- private: int m_x ;
- int m_y ;
- ICalculator* m_pCalculator;
- public: int calculate();
- setX(int);
- setY(int);
- setCalculator(ICalculator*);
Advertisement
Add Comment
Please, Sign In to add comment