Derived(const Derived& d) : Base(d) {
cout << "Derived::Derived(const B&)" << endl;
}
This calls the Base
copy constructor on the Base
sub-object of d
.
The answer for ‘why‘ I don‘t know. But usually there‘s no answer. The committee just had to choose one option or the other. This seems more consistent with the rest of the language, where e.g. Derived(int x)
won‘t automatically call Base(x)
.