Can you call a virtual function from a constructor or a destructor?
Show answer and explanation
A virtual call is legal in a constructor or destructor, but dispatch stops at the class currently being constructed or destroyed. More-derived parts are not active, and calling a pure virtual function in that situation is invalid.
A virtual call is legal in a constructor or destructor, but dispatch stops at the class currently being constructed or destroyed. More-derived parts are not active, and calling a pure virtual function in that situation is invalid.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.