Because Component contains a pointer to an Entity, it only knows about things that are in Entity--things that are common to ALL Entity subclasses. The Enemy class derives from Entity, so it contains everything in an Entity PLUS more stuff (in this case, TEST).

If you want to access TEST from within Component, then change the pointer to Enemy* entity;. Or, move TEST into the Entity base class. Otherwise, you are stuck accessing only things that are common to all Entities. At beginner levels of programming there is no way to know whether the object pointed to by Component::entity is an Enemy, and base class Entity, or something else derived from Entity.