Advertisement
193030

Untitled

Jan 6th, 2021
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //Base class
  5. class Person
  6. {
  7. protected:
  8.     double sum;
  9. };
  10.  
  11. class Employee : protected Person {
  12. public:
  13.     void Add(double input)
  14.     {
  15.         sum += input;
  16.         cout << "The sum after adding is " << sum << endl;
  17.     }
  18.  
  19.     void Substract(double input)
  20.     {
  21.         sum -= input;
  22.         cout << "The sum after substracting is " << sum << endl;
  23.     }
  24. };
  25.  
  26. int main()
  27. {
  28.  
  29.     Employee Empl;
  30.     Empl.Add(12);
  31.     Empl.Substract(10);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement