donmike25

incomplete q10_2

Jan 4th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class ICalculator
  5. {
  6. public:
  7.  
  8.     virtual int calculate(int x,int y) = 0;
  9. };
  10.  
  11. class Adder : public ICalculator
  12. {
  13. public:  
  14.     int Calculate(int x,int y)
  15. {
  16.     int s;
  17.     s=x+y;
  18.     return s;
  19. }
  20.  
  21. };
  22.  
  23.  
  24. class Multiplier : public ICalculator
  25. {
  26. public:
  27.     int Calculate(int x, int y)
  28.     {
  29.         int m;
  30.         m=x*y;
  31.         return m;
  32.     }
  33. };
  34.  
  35. class Problem
  36. {
  37. private: int m_x ;
  38.          int m_y ;
  39.  
  40.          ICalculator* m_pCalculator;
  41.  
  42. public:  int calculate();
  43.          setX(int);
  44.          setY(int);
  45.          setCalculator(ICalculator*);
Advertisement
Add Comment
Please, Sign In to add comment