Recently I attended an interview where a person asked me what the order of construction and destruction is. I explained that construction occurred from the foundation to the child and destruction from the child to the foundation.
The interviewer was fascinated by the fact that he knew if there was any particular reason for the destruction that occurred from the derivative to the base. I explained to him, but he was not convinced.
His thought was that if destroying a base class gives an exception, then as if the derived class knew that the object of the derived class was already destroyed.
He also said that a derived class contains members of a base class, so why can't we first cause the destruction of the base class?
I explained that after the destruction of the derived class, we cannot say that the object is completely destroyed.
I'm here? What is the best answer here?
source share