Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class A {
- protected:
- int i;
- public:
- A(int a) {
- i = a;
- cout << "A's constructor called" << endl;
- };
- };
- class B: A {
- private:
- A a_object;
- public:
- B(int a):A(a), a_object(a) {
- cout << "B's constructor called";
- };
- int get_value() {
- return a_object.i;
- }
- };
- int main() {
- B object(10);
- cout << endl;
- //cout << object.get_value();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement