home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uwm.edu!caen!saimiri.primate.wisc.edu!ames!sun-barr!sh.wide!fgw!fdm!flab!zodiac!zodiac!vander
- From: vander@flab.fujitsu.co.jp (Mike van der Velden)
- Newsgroups: comp.lang.c++
- Subject: Invoking template base ctor
- Message-ID: <VANDER.92Nov6115633@vancouver.stars.flab.Fujitsu.co.jp>
- Date: 6 Nov 92 02:56:33 GMT
- Sender: news@zodiac.hi.flab.fujitsu.co.jp
- Organization: Fujitsu Laboratories Ltd., Kawasaki, Japan
- Lines: 43
- Nntp-Posting-Host: vancouver.hi.flab.fujitsu.co.jp
-
-
- I'm using g++ (2.2.2?) on a Sun Sparc S-4/1X. I have the following
- code segment.
-
- template <class T>
- class B {
- public:
- B () { /* */ }
- };
-
-
- class D : public B<D> {
- public:
- D() : () {} // compiles fine
- D() : B() {} // error: class `D' does not have any field named `B'
- };
-
-
- I always used the second method of invoking the base class
- constructor, but the compiler complained about it. I was at wits end
- until I noticed that the ARM uses the first method in one of its
- examples in the section about templates (sorry, I left the book at
- home this morning, so I don't know the exact page number). This
- works, even though the ARM also states that the first method is the
- "old" way of calling a base class constructor.
-
- Note that if class B is a regular class, and not a template, then
- either method of invoking the base class constructor works.
-
- Is this correct behaviour (ie. since the ARM does it...) or a known
- deficiency in the g++ compiler? How can I achieve multiple
- inheritance in this case?
-
- Our AT&T compiler (version 2.1) doesn't even handle templates, so
- switching compilers at this point is not really an option...
-
- --
-
- --
- Mike van der Velden
- s-mail: Distributed Systems Laboratory, Fujitsu Laboratories Ltd.
- 1015, Kamikodanaka Nakahara-ku, Kawasaki 211, Japan
- e-mail: vander@flab.fujitsu.co.jp
-