[link]http://www.devmaster...oo-game-design/[/link]
From my understanding, every GameEntity & GameForm has a std::map<string, State&> States. Every type of State (i.e. AccelerationRate or something) is a class derived from State, and therefore can be stored in this hashtable via its base pointer/reference (the State portion).
My issue is accessing those State objects. Since I'll be storing a reference to the State base object and not its derived version, how do I access the derived object's members through the base object reference?
Look at this pseudo-code example:
class BaseClass {
public:
int baseint;
};
class DerivedClass: BaseClass {
public:
int derivedint;
};
void main () {
DerivedClass dc;
BaseClass &BCP = dc; // reference to the BaseClass portion of dc, which is derived
cout << BCP.derivedint; // *** THIS DOESN'T WORK, DOES IT?! ***
}












