How does creating an object of a class, runs the functions inside? |
When you create an object, constructors for all of its base classes are executed, then the constructors for all of its members are executed, and finally its own constructor is executed.
When you create
b1
(which is of type B, whose base class is A), the constructor for the base, A::A() is executed, then its own constructor, B::B() is executed.
When you create
c1
(which is of type C, whose base is B, whose base is A), the constructor for the base of the base, A::A() is executed, then the constructor of the base, B::B() is executed, then its own constructor, C::C() is executed.
Does class B: public A mean that class B has access to the public components of the class A? |
It means that public members of A are public members of B (and private members of A are private members of B)
Does class C : private B mean that class C has access to the Private components of the class B? |
It means that all members of B (public and private) as well as all members of A (public and private) are private members of C.