home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cimshop!davidm
- From: davidm@consilium.com (David S. Masterson)
- Newsgroups: comp.lang.c++
- Subject: Re: Virtual function call within constructors
- Message-ID: <DAVIDM.93Jan24145757@consilium.com>
- Date: 24 Jan 93 22:57:57 GMT
- References: <1993Jan24.051330.3721@dcc.uchile.cl>
- Sender: root@cimshop.UUCP
- Organization: Consilium Inc., Mountain View, California
- Lines: 29
- In-reply-to: gschwarz@dcc.uchile.cl's message of 24 Jan 93 05:13:30 GMT
- X-Posting-Software: GNUS 3.13 [ NNTP-based News Reader for GNU Emacs ]
-
- >>>>> On 24 Jan 93 05:13:30 GMT, gschwarz@dcc.uchile.cl (Guillermo Schwarz
- >>>>> Utrup) said:
-
- > I have found that virtual functions are not handled as one could expect
- > when called from a constructor.
-
- Actually, it works exactly as expected according to the definition of C++.
- You must realize that the parts of a class are not really available for use
- until the constructor of that class has been called. Therefore, if you have a
- class definition like:
-
- A -> B -> C
-
- then you know that, when constructing C, A and B must first be constructed.
- Except for virtual functions, there is no way that A or B will try to make use
- of some part of C. When a virtual function is called, then the most derived
- version of that virtual function that is currently available will be called.
- The thing to realize is that while the A part of C is being constructed, then
- the B and C parts of it are not yet available.
- --
- ====================================================================
- David Masterson Consilium, Inc.
- (415) 691-6311 640 Clyde Ct.
- davidm@consilium.com Mtn. View, CA 94043
- ====================================================================
- I'm opposed to these unsupervised weekend furloughs for first-degree
- murderers.
- -- George Bush, asked whether the Pledge of Allegiance
- would be his only campaign issue in 1988.
-