sway you create a class, on top of a base class called , CEntity, and the clhild class is call Player.
is there a way you could do
CEntity* CreateInstance (CEntity temp);
via
CreateEntity(Player);
is three any way to do this?
If Player extends CEntity, Player can act as a CEntity type. CEntity can however not act as a Player type.
So if your method takes a CEntity type as an argument, then yes you can give it a Player type without any problems. Just remember that you can only access the methods on the Player type it has inherited from CEntity, not any new methods you've created in the player class.
So if your method takes a CEntity type as an argument, then yes you can give it a Player type without any problems. Just remember that you can only access the methods on the Player type it has inherited from CEntity, not any new methods you've created in the player class.
sway you create a class, on top of a base class called , CEntity, and the clhild class is call Player.
is there a way you could do
CEntity* CreateInstance (CEntity temp);
via
CreateEntity(Player);
In what language?
In general, that's a fairly odd way to do it. Usually you'll see a clone method that copies the existing instance or some string/identifier to create a new specific instance from nothing.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement