Original Post
Hi everyone,
I''m trying to use a std::vector object of some base class objects, then recast them depending upon their type...
ie
as you can tell, once I''ve determined which type of Entity object I''m dealing with, I want to re-cast it to the proper subclass of Entity to access the member variables/methods I need..
I know I''m doing the recasting wrong (line 12), but am I also doing the original Entity object grab wrong? (line 4)??
thanks for any help!
1. for(std::vector<Entity>::iterator i = m_vecEntities.begin();
2. i != m_vecEntities.end(); ++i){
3.
4. Entity &ThisClass = *i;
5.
6. //now do a switch depending upon the entity type
7. switch(ThisClass.dwType){
8. case ASTEROID_ENTITY:
9. /****************************
10. ** THIS IS THE LINE THAT BREAKS **
11. ********************************/
12. Asteroid oRock = (Asteroid)ThisClass; //????