Tuesday, November 30, 2010
What the compiler could mark as an error
Never call virtual functions from within constructors of the same class. This can lead to an access violation. The call will be dispatched to the the overridden function. Now imagine there's a derived class which holds this override. In case the base class constructor calls the polymorphic function the dispatch is done before the derived class instance is constructed entirely - slicing. Got it? This function will access fields which are'nt there at all.