From -3173078655901168289 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,cc5b2194d357e113 X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2003-02-21 14:00:38 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull From: greg.hickman@lmco.com (Greg Hickman) Newsgroups: comp.std.c++ Subject: Re: Virtual Base Constructors Date: Fri, 21 Feb 2003 22:00:36 +0000 (UTC) Organization: Lockheed Martin Corporation Lines: 76 Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: References: <58F604E3D17AD4119D8600508BE325060EA9A2F1@emss07m04.lmtas.lmco.com> <1trs9ECfMhV+Ew9M@robinton.demon.co.uk> Content-Transfer-Encoding: 7BIT X-Trace: mail2news.demon.co.uk 1045864836 605 10.0.0.1 (21 Feb 2003 22:00:36 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Fri, 21 Feb 2003 22:00:36 +0000 (UTC) X-Received: from mulga.cs.mu.oz.au ([128.250.1.22]) by news.demon.co.uk with esmtp (Exim 4.05) id 18mLDe-00009c-00 for mail2news@news.news.demon.net; Fri, 21 Feb 2003 22:00:34 +0000 X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU id JAA15621; Sat, 22 Feb 2003 09:00:29 +1100 (EST) X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Path: comp-std-cpp-robomod!not-for-mail X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Delivered-To: std-c++@ncar.ucar.edu X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Priority: 3 X-MSMail-priority: Normal X-Newsgroups: comp.std.c++ X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MailScanner: PASSED (v1.2.7 41336 h1LLJcsI062221 mailbox1.ucsd.edu) X-Spam-Status: No, hits=-4.5 required=5.0 tests=INVALID_MSGID,NOSPAM_INC,PRIORITY_NO_NAME, QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01 version=2.41 Xref: archiver1.google.com comp.std.c++:18011 "Francis Glassborow" wrote in message news:1trs9ECfMhV+Ew9M@robinton.demon.co.uk... > In article > <58F604E3D17AD4119D8600508BE325060EA9A2F1@emss07m04.lmtas.lmco.com>, > "Hickman, Greg" writes > >If a compiler can ascertain that a class with a virtual base isn't > >instantiable, wouldn't it be possible to allow that class to omit calling > >the constructor of the virtual base since it will have to be called by a > >more derived class anyway? > > > >For example, > > > >class Io_object { > >public: > > virtual ~Io_object() {} > > virtual void read_from(const Io_reader&) = 0; > > virtual void write_to(const Io_writer&) const = 0; > >protected: > > Io_object(const Io_type&); > > As this is already an ABC what is this for in a stateless class. Sorry, I engaged in a little too much eliding, as it were. I meant to imply (psychic-ly) by the presence of the constructor that the base did in fact have some data. For example, class Io_type { public: explicit Io_type(const char* name) : name_(name) {} //... private: const char* name_; }; class Io_object { public: // ... protected: Io_object(const Io_type& type) : type_(type) {} private: Io_type type_; }; class Base : public virtual Io_object { // this is abstract public: //... protected: Base(const Io_type& type) : Io_object(type) {} }; class Concrete : public Base { public: Concrete(); //... private: static const Io_type type_; }; Concrete::Concrete() : Io_object(type_), Base(type) { } It seems superfluous for Base to supply a call to the Io_object constructor since Base has to be derived from before it can be instantiated, and it's the most derived class that will ultimately have to call the constructor for the Io_object virtual base anyway. Greg --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]