VehicleGameObject pVehicleObj = Find_My_Vehicle();
GameObject* pObject = dynamic_cast<GameObject*>(pVehicleObj);
Or...
GameObject* pObject = dynamic_cast<GameObject*>(Find_My_Vehicle());
Or...
GameObject* pObject = (GameObject*)Find_My_Vehicle();
(PS: If you didn't already figure it out, VehicleGameObject *is* a GameObject, since it's a derived class)
(PPS: Yes, I know dynamic casting a subclass to its superclass is redundant since it's always going to succeed, just illustrating my point )
[Updated on: Thu, 06 October 2011 07:14]
Report message to a moderator