Guest User

Untitled

a guest
Nov 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. public:
  6.   A () : a(5), b(6) {}
  7.   A (int _a, int _b) : a (_a), b(_b) {}
  8.   A& operator= (const int& right) { a = right + b; };
  9.   void print() { std::cout << "a=" << a << "; b=" << b << std::endl; }
  10.  
  11. private:
  12.   int a;
  13.   int b;
  14. };
  15.  
  16. class B : public A
  17. {
  18. public:
  19.   B () : A (10, 20) {}
  20. };
  21.  
  22.  
  23. int main ()
  24. {
  25.   A aaa;
  26.   aaa=20;
  27.   aaa.print ();
  28.   B bbb;
  29.   bbb=150;
  30.   bbb.print();
  31.   return 0;
  32. }
Add Comment
Please, Sign In to add comment