Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #578

Re: Inheritance of constructor/desctructor

Path csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From James Kuyper<jameskuyper@verizon.net>
Newsgroups comp.std.c++
Subject Re: Inheritance of constructor/desctructor
Date Thu, 20 Dec 2012 11:49:30 -0800 (PST)
Organization A noiseless patient Spider
Lines 46
Sender std-cpp-request@vandevoorde.com
Approved stephen.clamage@oracle.com
Message-ID <50D2553E.2020602@verizon.net> (permalink)
References <CAJXMFhF-n8h9BukGPDga6cqjzKb2L3PchEJX4vhy+4X+Ng_AYg@mail.gmail.com>
NNTP-Posting-Host FKrB7G4cFV6k/ey+xSo3RkpfJ2FXYeQJe6js4txZ21w=
Content-Type text/plain; charset=ISO-8859-1
X-Trace news.albasani.net 6ixEL4bpMJcnX5sy8TOd9UWFcyEFjSancCX4JzKzap3yXyxTaE5CkeRIqV5+OpQ4G/9bXYezkf1FOk2CRwArvA==
X-Complaints-To abuse@albasani.net
NNTP-Posting-Date Thu, 20 Dec 2012 19:49:32 +0000 (UTC)
X-Mailer Perl5 Mail::Internet v2.05
X-Submission-Address std-cpp-submit@vandevoorde.com
Cancel-Lock sha1:mICPhMAqnNWuARl9qjBJnzrJyBs=
X-Original-Date Wed, 19 Dec 2012 19:01:02 -0500
Xref csiph.com comp.std.c++:578

Show key headers only | View raw


On 12/19/2012 05:20 PM, J B wrote:
>  Hi,
>
>  I have a question about definition of inheritance (perhaps as stated in C++
>  ISO docs somewhere).
>
>  Somebody claimed that when one class is derived from another, then the base
>  class' constructors and desctructors are inherited by the derived class.
>
>  Let's consider the simplest case:
>  class Base {};
>  class Derived: public Base {};
>
>  I tend to disagree and this is my argument:
>
>  The definition of inheritance (biologic, scientific,  etc) states that it is
>  an acquisition of traits genetically transmitted from parent to offspring.
>  Well, in that case those traits in a parent are not modifiable by an offspring
>  in any way, only some of parent's "blueprint" is utilized in creation
>  of offspring's
>  "blueprint".
>
>  So, a derived class does not inherit constructors and desctructors of a base
>  class.

The C++ standard defines what it means by "inheritance"; any conflicting
concept of inheritance derived from the meanings that same word has in
biological or legal contexts should be ignored.

The C++ standard has an entire section (12.9) devoted to "Inheriting
constructors", so I think that constructors can be inherited - but what
that section is talking about is probably quite different from what
you're talking about. It's not something that automatically occurs just
because one class is derived from another. It specifically requires the
use of a using-declaration, such as

     struct D1 : B1 {
         using B1::B1;
     };


-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Find similar


Thread

Inheritance of constructor/desctructor J B<jb.1234abcd@googlemail.com> - 2012-12-19 14:20 -0800
  Re: Inheritance of constructor/desctructor James Kuyper<jameskuyper@verizon.net> - 2012-12-20 11:49 -0800

csiph-web