digitalmars.D.learn - constructors of nested classes
- Manfred Nowak (43/43) Aug 13 2005 from the specs:
from the specs: | If no call to constructors via this or super appear in a | constructor, and the base class has a constructor, a call to | super() is inserted at the beginning of the constructor. | | If there is no constructor for a class, but there is a | constructor for the base class, a default constructor of the | form: | | this() { } | | is implicitly generated. There is no deviation from this marked in the section "Nested Classes". According to this the code: class A{ class B:A{ } B b; this(){ b= new B; } } is implicitely transformed to: class A{ class B:A{ this(){ super(); } } B b; this(){ b= new B; } } But then every instantiation A a= new A; should generate an infinite loop of constructor calls. However, programs compiled by dmd do not expose an infinite loop. But, if an empty constructor is inserted into B, an infinite loop is generated. What am I missing? -manfred
Aug 13 2005