home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!stanford.edu!agate!linus!linus.mitre.org!schaffner
- From: sch@mitre.org (Stu Schaffner)
- Subject: Re: Constructors in C++
- Message-ID: <sch-270892163047@schaffner.mitre.org>
- Followup-To: comp.lang.c++
- Sender: news@linus.mitre.org (News Service)
- Nntp-Posting-Host: schaffner.mitre.org
- Organization: MITRE Corp.
- References: <1992Aug27.155652.11995@kakwa.ucs.ualberta.ca>
- Date: Thu, 27 Aug 1992 20:40:27 GMT
- Lines: 29
-
- In article <1992Aug27.155652.11995@kakwa.ucs.ualberta.ca>,
- jimmy@namao.ucs.ualberta.ca wrote:
- >
- > Does a constructor with parameters call the default constructor ? I am
- > a novice, so please do not laugh.
- > Thanks,
- > Jimmy
- >
- > jimmy@namao.ucs.ualberta.ca
- >
- > --
- > jimmy@namao.ucs.ualberta.ca
-
- Nothing to laugh about ... there are a number of subtleties associated with
- constructors. The short answer is no, nor should you call the default
- constructor explicitly in the nondefault constructor. Recall that a
- constructor really does two things in sequence: initialize the object
- enough that methods can be called, then execute a constructor body. A call
- in that body to another initializer would repeat the initialization.
-
- There is a good explanation of all of this in Ellis & Stroustrup, "The
- Annotated C++ Reference Manual", sometimes called "the ARM" (ISBN
- 0-201-51459-1. In the 1990 version, at least, it starts on page 262. This
- also gives an example of how to factor out code common to more than one
- constructor.
-
- Stu Schaffner, not speaking for
- The MITRE Corp.
- sch@mitre.org
-