elloco999
Well-known member
- Joined
- Dec 21, 2004
- Messages
- 49
- Programming Experience
- 5-10
Hi,
I'm trying to write a simple game. In this game the player has an inventory, that can contain several objects. An object is a class thet inherits from base class Object_Base. In OjectBase the objects name, weight and price are stored.
A ligth armor is such an object. A light armor is an instance of the class Armor. The values that are specific for an armor are stored in this class, such as armor hitpoints.
To be able to store several instances of different classes (such as a light armor, a medium armor and an Glock 19 (class Weapon)) I have declared an array of class Object_Base.
Now, if I want to get the name of an object I use: Objects(0).GetName() (function of class Object_Base), but to get the hitpoints left of the light armor I will need to call lightArmor.GetHitPoints()
So, here's my question: How can I call a function of class armor when the armor in question is in an array of class Object_Base? If I call Objects(0).GetHitPoints() It doesn't work (because it's not an function of Object_Base)
Greetz,
El Loco
I'm trying to write a simple game. In this game the player has an inventory, that can contain several objects. An object is a class thet inherits from base class Object_Base. In OjectBase the objects name, weight and price are stored.
A ligth armor is such an object. A light armor is an instance of the class Armor. The values that are specific for an armor are stored in this class, such as armor hitpoints.
To be able to store several instances of different classes (such as a light armor, a medium armor and an Glock 19 (class Weapon)) I have declared an array of class Object_Base.
Now, if I want to get the name of an object I use: Objects(0).GetName() (function of class Object_Base), but to get the hitpoints left of the light armor I will need to call lightArmor.GetHitPoints()
So, here's my question: How can I call a function of class armor when the armor in question is in an array of class Object_Base? If I call Objects(0).GetHitPoints() It doesn't work (because it's not an function of Object_Base)
Greetz,
El Loco