Class and Enum Interactions

Posted 08 January 2013 - 12:07 PM

So, im relatively new to programming, and I have a tutor that has given me an assignment based on our last lesson but I have run in to a problem with something that I dont understand based on the following code:

enum OBJECT_TYPE // Creation of a data type
{
// Individual data types
OT_ROOM,
OT_TOOL,
OT_PUZZLE,
OT_NOUN,
OT_VERB,
OT_MAX_OBJECT_TYPE
};
class OBJECT_ID // Class to call when using an object from OBJECT_TYPE
{
public: // Seen and used by any outside source
OBJECT_ID() // Default constructor - Called if nothing else can be
{
type_of_object = OT_MAX_OBJECT_TYPE; // Makes type_of_object (as in private) the value of OT_MAX_OBJECT_TYPE, or the max and illigitimate value
}
OBJECT_ID(OBJECT_TYPE intype) // Primary constructor - called when requested with a defining value from the enum
{
type_of_object = intype; // Assigns type_of_object the value sent to the class when it was called
}
~OBJECT_ID(); // Destroys the object
private: // seen only by the class itself
OBJECT_TYPE type_of_object; // Declares an enum value called type_of_object
};
class TOOL : public OBJECT_ID // A class that interacts with the OBJECT_ID class as its parent
{
public: // Seen and used by any outside source
TOOL() : OBJECT_ID(OT_TOOL) // Default constructor called by OBJECT_ID with a value of OT_TOOL
{
}
~TOOL();
private: // seen by only the class itself

What im TRYING to do is have it be possible for OBJECT_ID to identify for what enum value its been called for and run the appropriate class as such, but, I just realised (the next day after the lesson... lol) that I never asked how one class can point to running code from another?

TOOL() : OBJECT_ID(OT_TOOL) // Default constructor called by OBJECT_ID with a value of OT_TOOL

as far as I know this line does what I commented it as, and if im not wrong then there needs to be another line of code to make this one happen?

thanks for the help!
AJ

This post has been edited by macosxnerd101: 08 January 2013 - 12:45 PM
Reason for edit:: Please use a more descriptive title