home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Virtual function call within constructors
- Message-ID: <1993Jan24.164709.18400@taumet.com>
- Organization: TauMetric Corporation
- References: <1993Jan24.051330.3721@dcc.uchile.cl>
- Date: Sun, 24 Jan 1993 16:47:09 GMT
- Lines: 23
-
- gschwarz@dcc.uchile.cl (Guillermo Schwarz Utrup) writes:
-
- To: gschwarz@dcc.uchile.cl
- Subject: Re: Virtual function call within constructors
- Newsgroups: comp.lang.c++
- References: <1993Jan24.051330.3721@dcc.uchile.cl>
-
- In comp.lang.c++ you write:
-
- >I have found that virtual functions are not handled as one could expect
- >when called from a constructor.
-
- That is because you are not expecting the right thing. Look up
- virtual functions in constructors in any good C++ text.
-
- When constructing a base class, only functions visible from that class
- constructor can be called. The derived class has not been constructed yet,
- so you can't call any of its functions. For example, the derived version
- of the virtual function might depend on data set up by the derived
- constructor, which won't have yet been called.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-