🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #310338

Re: Różne nazwy konstruktora?

#310338
From: Wojciech Muła
Date: Wed, 23 Dec 2020 15:22
30 lines
1932 bytes
On Wednesday, December 23, 2020 at 3:22:35 AM UTC+1, M.M. wrote:
> Trochę inne zagadnienie związane z konstruktorami, które zawsze mnie denerwowało w C++. 
> Poniższy kod w C++ się nie skompiluje: 
> 
> class A { 
> int a; 
> public: 
> A(const int a):a(a) { 
> } 
> }; 
> class B : public A { 
> }; 
> int main() 
> { 
> B b(3); 
> return 0; 
> } 
> 
> Natomiast odpowiedni kod w PHP działa bez zarzutu. Co by było złego, gdyby w C++ 
> konstruktory 'były dziedziczone' ? 

Od C++11:

class B: public A {
    using A::A;
};

Więcej na https://en.cppreference.com/w/cpp/language/using_declaration

w.
Technical Details
Message-ID: <5f9874c8-994e-4a0a-a128-b208e70e9559n@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
References: <5fce7cbf$0$554$65785112@news.neostrada.pl> <48755639-7648-40b4-a759-609bafdc9f05n@googlegroups.com> <efaebb19-3d42-4280-9763-b6e4591fbef9n@googlegroups.com>

Show Full Headers
Complete Article Headers
X-Received: by 2002:aed:2742:: with SMTP id n60mr26341885qtd.221.1608736949333;        Wed, 23 Dec 2020 07:22:29 -0800 (PST)
X-Received: by 2002:a05:620a:1512:: with SMTP id i18mr27763589qkk.470.1608736949045; Wed, 23 Dec 2020 07:22:29 -0800 (PST)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: pl.comp.lang.c
Date: Wed, 23 Dec 2020 07:22:28 -0800 (PST)
In-Reply-To: <efaebb19-3d42-4280-9763-b6e4591fbef9n@googlegroups.com>
Complaints-To: groups-abuse@google.com
Injection-Info: google-groups.googlegroups.com; posting-host=46.134.38.218; posting-account=VFwkXwoAAADdT4-lLKRZrMYkTjizGoyn
NNTP-Posting-Host: 46.134.38.218
References: <5fce7cbf$0$554$65785112@news.neostrada.pl> <48755639-7648-40b4-a759-609bafdc9f05n@googlegroups.com> <efaebb19-3d42-4280-9763-b6e4591fbef9n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5f9874c8-994e-4a0a-a128-b208e70e9559n@googlegroups.com>
Subject: Re: Różne nazwy konstruktora?
From: Wojciech Muła <wojciech_mula@poczta.onet.pl>
Injection-Date: Wed, 23 Dec 2020 15:22:29 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit