public class A
{ int a; public A(int a) {this.a = a;} }
public class AB : A
{ int a; int b; public AB(int a, int b) : base(a) { this.b = b; } }
public class ABC : AB
{ int a; int b; int c; public ABC(int a, int b, int c) : AB(a, b) { this.c = c; } }
The call of AB(a, b) in ABC() is forbidden. All I can use there seems to be this() or base().
Is there a way to call the constructor of the closest parent, not the one of the oldest ancestor?
Loading
joakim wireenPosted Apr 12, 2009, 11:36 AM
The only way of reaching a constructor is by creating an instance of the class. So if you know the name simply just create a new instance of the class and the constructor will be called.
ZagielPosted Apr 7, 2009, 7:45 AM
joakim wireenPosted Apr 7, 2009, 3:12 AM