Same class for inheriting and private member

Hello all,

I would like to know if it is possible to create a class Y which at the same time:
1) inherits from a class X
2) has a private member of class X

Is it possible?

Thnaks,
Antonio
It would take you a minute to try..
(yes)
Do you mean something like this?
1
2
3
4
5
6
7
8
9
10
11
class X {
  private:
    type_t a;
  // more things
};

class Y: public X {
  private:
     using X::a;
  // more things
};
Thanks hamsterman.

isnork, I meant something like:

1
2
3
4
5
6
7
8
9
class X {
  // more things
};

class Y: public X {
  private:
     X myPrivateObject;
  // more things
};
@isnork
That is illegal, and defeats the purpose of private storage class.
It is also a really bad idea. Descendant classes should not be messing with the private internals of their ancestor classes.
Topic archived. No new replies allowed.