Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class A
- {
- public:
- A () : a(5), b(6) {}
- A (int _a, int _b) : a (_a), b(_b) {}
- A& operator= (const int& right) { a = right + b; };
- void print() { std::cout << "a=" << a << "; b=" << b << std::endl; }
- private:
- int a;
- int b;
- };
- class B : public A
- {
- public:
- B () : A (10, 20) {}
- };
- int main ()
- {
- A aaa;
- aaa=20;
- aaa.print ();
- B bbb;
- bbb=150;
- bbb.print();
- return 0;
- }
Add Comment
Please, Sign In to add comment