home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!uwm.edu!ogicse!hsdndev!husc-news.harvard.edu!husc10!robison1
- From: robison1@husc10.harvard.edu (Keith Robison)
- Newsgroups: comp.lang.c++
- Subject: Re: Overriding the order of constructors?
- Keywords: constructor ordering
- Message-ID: <robison1.724307343@husc10>
- Date: 14 Dec 92 04:29:03 GMT
- References: <1992Dec13.220943.22047@jarvis.csri.toronto.edu>
- Lines: 35
- Nntp-Posting-Host: husc10.harvard.edu
-
- dembo@csri.toronto.edu (Prof. Ron Dembo) writes:
-
-
-
- >What is the rational for not allowing a programmer to override the
- >default calling order of constructors and initializers? I see
- >the importance of having a well defined default. However, why
- >shouldn't the ordering of the initilizers be significant?
-
-
- I believe you can effectively accomplish this dangerous
- goal by calling virtual functions in your constructors:
-
-
- class A {
- A() { reroute(); do_A_ctor_stuff(); }
- virtual void reroute(); { }
- }
-
- class B : public A {
- B() {}
- void reroute () { do_B_ctor_stuff(); }
- }
-
-
- This will cause B's reroute() to be executed before any
- A constructing has occurred.
-
-
- Keith Robison
- Harvard University
- Department of Cellular & Developmental Biology
- Department of Genetics / HHMI
-
- robison@biosun.harvard.edu
-