0

I am creating a class and I want to have a parent class of the same class

class human{
   public:
      human parent;
      
}
  • 2
    That will cause a circular reference in the constructor. I.e. not possible. The class definition for value types has to be complete. There's an issue with the design: you don't want the "child" to own the "parent". You probably want a reference (`human&`) or pointer (`human*`). Those are allowed when the class definition is not complete. – JHBonarius Feb 28 '22 at 12:11
  • 1
    if every `human` contains a `human` and no `human` has no `parent` then every `human` is made of an infinite number of `human`s. – 463035818_is_not_an_ai Feb 28 '22 at 12:33

0 Answers0