Order of base-class constructor calls
    Steven Schveighoffer 
    schveiguy at yahoo.com
       
    Wed Oct 12 07:31:53 PDT 2011
    
    
  
On Tue, 11 Oct 2011 12:40:29 -0400, Andrej Mitrovic  
<andrej.mitrovich at gmail.com> wrote:
> Nope. Private ctors have to be called from within the same module,
> whether implicit or not:
>
> test.d:
> class Foo
> {
>     private this() { }  // Error: constructor main.Bar.this no match
> for implicit super() call in constructor
> }
>
> import test;
> class Bar : Foo
> {
>     this() { }
> }
>
> void main()
> {
>     auto bar = new Bar();
> }
Hm... that makes sense.
You can try mucking around with roll-your-own construction.  That is,  
ignore the constructor and use a mixture of public final initialize  
functions + protected virtual initialize functions.
It might just be something that you have to accept is not definable by the  
base class :(
C++ requires construction of base classes before the main body of a  
derived constructor is called.  And that has its own problems too...
-Steve
    
    
More information about the Digitalmars-d-learn
mailing list