a question, please help me answer
1)Consider a single inheritance where class D inherits from class B. Now when i create an object of class D in main(), constructor of class B is invoked before the class D constructor, and class D destructor is invoked before class B destructor. Why does this happen?
The construction order is done that way because typically your parent may allocate memory that the child constructor is going to utilize. So the parent must set everything up before the child can use it.
And for destruction, the child must remove any memory or handlers to the data before it's cleared by the parent class.