Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,878 of 33,346    |
|    Seungbeom Kim to omveer    |
|    Re: Virtual base class and friend    |
|    01 Mar 13 00:17:11    |
   
   From: musiphil@bawi.org   
      
   On 2013-02-28 04:16, omveer wrote:   
   > Thanks to Tobias Müller. I got below response.   
   >   
   [...]   
   >   
   > Consider the following case:   
   >   
   > class A   
   > {   
   > public:   
   > A();   
   > A(int i);   
   > };   
   >   
   > class B : virtual public A   
   > {   
   > public:   
   > B() : A() {}   
   > };   
   >   
   > class C : virtual public A   
   > {   
   > public:   
   > C() : A(4) {}   
   > };   
   >   
   > class D : public B, public C   
   > {   
   > public:   
   > // D() : B(), C() {} // -> Error, the A subobject   
   > // is the same for B and C   
   > // and can only be   
   > // constructed once. But use   
   > // A() or A(4)?   
      
   This is not an error, because it needs to construct A and the default   
   constructor of A is accessible from D. It doesn't matter how the c'tors   
   of B and C are defined to construct A; they are simply ignored.   
      
   > D() : A(), B(), C() {} // Correct   
      
   This is identical to the previous constructor (commented out).   
      
   > };   
      
   --   
   Seungbeom Kim   
      
      
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca