I'm a bit new to C++, so excuse me if this is a stupid question.
I have a class "AItem", where each AItem can contain child AItems. I thought this should be a pretty straightforward thing to do, but clearly my understanding of C++'s pointers is letting me down.
I had thought I could just use...
typedef std::list<AItem> AItemList;
And then define...
... in my class.
It seemed to be working, but then when I started trying to access children, I got strange results.
I reread the documentation on list::push_back and found this...
"The content of this new element is initialized to a copy of x."
Certainly not what I wanted. I don't want it to store "a copy of x" I want it to store x!
Maybe I should just use a dynamic array? What would you recommend?
This seems like a pretty common thing to do, having a hierarchy of object applies to all sorts of applications, so surely it should be hard!