Base Class Hitting Derived Class Invariant

Jonathan M Davis jmdavisProg at gmx.com
Sun Nov 11 19:39:30 PST 2012


On Monday, November 12, 2012 04:32:51 Vijay Nayar wrote:
> If the base class constructor needs to occur before the derived
> class constructor, is there a good way to solve this without
> getting rid of the invariant?

Don't call virtual functions inside the constructor if you don't want any 
functions to invoke the derived class' invariant. If you need something done 
in the derived class, then do it in the derived class' constructor rather than 
a virtual function called by the base class constructor.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list