You wrote an infinitely recursive function. Your Cell::Cell
constructor indirectly calls itself thorough new
expression, which in turn calls Cell::Cell
again, again and again... This eventually leads to stack overflow and crash.
(Also, it is not possible to have an explicit array of Cell
objects inside a Cell
object. Such a data structure would be infinitely nested, i.e. it would have infinite size.)
Note that there's nothing generally wrong with recursion per se. But it has to end at some point. If you want to build your tree recursively, you can do so, but you have to make sure your recursion bottoms-out at one point or another. I.e. your tree has to have leaf nodes. What you have now is a tree without leaf nodes. It is an infinite recursion that attempts to build an infinitely large tree. This is not possible. It makes no sense.
When it is time to build your leaf nodes - only you can answer. We don't know what kind of tree your are trying to build.