If every bag contains another bag....
Then bag 1 contains bag 2, which contains bag 3, which contains bag 4, which contains bag 5, etc, etc, etc. It goes on forever.
This is what is happening when you put a Base object inside the Base class.
On the other hand... if every bag has a slip of paper that has the address of where to find a bag, that's not a problem.
This is what is happening when you put a Base pointer inside a Base class.
Last edited on