View Single Post
Re: C++ overriding methods using virtual
Old
  (#14)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: C++ overriding methods using virtual - 22-06-2004

oh man... the confusion

The current "CVAR" is updated when a player enters a client command of a valid bot command. The valid bot command will be a pointer to a subclass instance of CBotCvar.

All the valid commands are held in a list of CBotCvar pointers. I need this as this is the only way to have a heterogeneous list of objects (eg. vector<CBotCvar*> m_BotCvars for the list).

I cannot make a list of completely different objects using OO methods, I don't think so anyway.

When the CBotCvar is matched by the cvarname (a string held in the CBotCvar class) it will call the action method. If the retrieved instance is derived from the CBotCvar class it will call it's own action method if it exists, so it will do it's own stuff. (e.g. If the retrieved CBotCvar* pointer from the list is derived from CBotMenuCommand class, it will call CBotMenuCommand 's action() method)

I'm sure this is the basic stuff of OO dynamic dispatching... certainly in Java, much stuff in Swing is done like this.

believe me, it works!!!

(I've updated my bot source on my site with the stuff... bot.h/bot_commands.h/bot_commands.cpp has the stuff)

Last edited by Cheeseh; 22-06-2004 at 02:34.. Reason: ohh my sore head...
  
Reply With Quote