Quote:Original post by psyjax
My linked lists are stored using the STL List template, so it shouldn't be a problem with the whole pointer thing considering that the STL List takes pointers anyway. A porgrammer friend of mind suggested that I should be able to typecast my derived class into a linked list of the parent class.
You don't even need to explicitly typecast:
// given thisclass Sprite {};class MySprite : public Sprite {};// and thisstd::list<Sprite*> AllSprites;// this is perfectly valid code:AllSprites.push_back(new Sprite());AllSprites.push_back(new MySprite());
Just be careful you don't throw any pointers to temporary (or stack-based) sprite objects into the list (i.e. local Sprite variables) as you'll end up causing invalid access exceptions.
Regards,
Jeff