An object can only be initialized once: when it first appears.
A initializes all its member variables in its constructor (before its constructor is executed). Thus, B cannot initialize the member variable from A , since the member variable has already been initialized by constructor A
(In this particular case, technically, i remains uninitialized because A did not initialize it, however, it is still A responsible for initializing its member variables.)
source share