Since the type is incomplete the compiler has no way of determinng it's size. Since the size is needed to store the objects by value the compiler whines about it. If you must deal with incomplete types you will need to use a container of pointers. For instance in Test
you can use std::vector<std::unique_ptr<IncompleteType>>
or std::vector<IncompleteType*>
.
There is another issue in your code. tree
and vector
fail with AbstractClass
because you are trying to store it by value. Since it has pure virtual functions it cannot be instantiated when the Node
is created.