Originally Posted by
Asagohan
Yes i have list<item> which stores all the items. Could you give me a short example in code which demonstrates what you said because i dont exactly understand what you mean.
I guess you are doing sth like this
Code:
list<item> items;
apple a;
items.push_back(a);
banana b;
items.push_back(b);
Since the list items holds only item's push_back will only store the item-part of the apple's and bananas. ( this is called slicing ).
you have to do it this way;
Code:
list<item*> items;
apple * pa= new apple;
items.push_back(pa);
banana * pb= new banana;
items.push_back(pb);
for ( list<item*>::iterater i = items.begin(); i != items.end(); ++i )
(*i)->disInfo();