|
|
От: |
desco
|
http://v2matveev.blogspot.com |
| Дата: | 11.07.06 07:21 | ||
| Оценка: | 1 (1) | ||
J>class Obj1
J>{
J> public Obj1(int x);
J>}
J>class Obj2 : Obj1
J>{
J>}
J>...
J>Obj2 obj = new Obj2(10);
J>17.10.1 Constructor initializers
All instance constructors (except those for class object) implicitly include an invocation of another
instance constructor immediately before the constructor-body. The constructor to implicitly invoke is
determined by the constructor-initializer:
• An instance constructor initializer of the form base(argument-listopt) causes an instance constructor
from the direct base class to be invoked. That constructor is selected using argument-list and the
overload resolution rules of §14.4.2. The set of candidate instance constructors consists of all accessible
instance constructors declared in the direct base class, or the default constructor (§17.10.4), if no
instance constructors are declared in the direct base class. If this set is empty, or if a single best instance
constructor cannot be identified, a compile-time error occurs.
...
<skipped>
...
If an instance constructor has no constructor initializer, a constructor initializer of the form base() is
implicitly provided. [Note: Thus, an instance constructor declaration of the form
C(…) {…}
is exactly equivalent to
C(…): base() {…}
end note]