View Single Post
Re: C++ overriding methods using virtual
Old
  (#10)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: C++ overriding methods using virtual - 21-06-2004

with that virtual functions, I guess you somehow got the sense of them wrong. a virtual function from a super class where the function exists in a subclass will never be called, unless you declare it explicitly like stated above. the whole virtual stuff wouldnt make much sense if you couldnt have a pointer to a base class and then without knowing what type of element it is, calling that function. depending if the instance is some subclass with its own function, or only the super class, the appropriate function will be called.

and it's also maybe a naming problem here. So you call e.g. all those BASE class in the HLSDK mainly superclasses, derived classes subclasses, right ? There is a lot of naming differences around, so that's maybe a problem too

and about constructors : yes, you have to get clear to see when which constructor gets called, but then it's advisable to use them to avoid initializing twice or even more. and the calling of constructors with this type of class config makes sense, since you want only to initialize the member variables. Sometimes it's getting a bit scary when you have no default ctor, but well, then you just have to do it via a : and then the base constructor with the arguments.

like this e.g. :
Code:
class CBV_HLDM_HideReload:public CBehaviour,CCallback_onPathCreation,CCallback_onReachedDestination{

public:

CBV_HLDM_HideReload(CBaseBot *pBot):CBehaviour(pBot){strcpy(m_szName,"CBV_HLDM_HideReload");}


  
Reply With Quote