Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!ai-lab!rice-chex!rpk From: rpk@rice-chex.ai.mit.edu (Robert Krajewski) Newsgroups: comp.lang.c++ Subject: Re: Virtual functions used in constructor illegal ! ?? Summary: Phylogeny recapitulates ontogeny. Keywords: virtual functions, constructor Message-ID: <12044@life.ai.mit.edu> Date: 26 Nov 90 22:54:09 GMT References: <822@orthogo.UUCP> <39733@ucbvax.BERKELEY.EDU> Sender: news@ai.mit.edu Organization: MIT Artificial Intelligence Laboratory Lines: 15 If the base class constructor could use a function designed to be used with a derived class instance, that (derived) function might try to refer to data members that weren't yet initialized. In a sense, an object ``evolves'' as more and more specialied constructors are run. The problem is that we would like the C++ constructor and destructor mechanism to handle *all* the semantics of creating and destroying and object, including tasks that must be invoked (using virtual functions) on all members of base class from which other classes are expected to be derived. You can get around this calling separate functions for initialization and deletion, but such a technique is awkward for stack-allocated objects. ---- Robert P. Krajewski Internet: rpk@ai.mit.edu ; Lotus: robert_krajewski.lotus@crd.dnet.lotus.com