Can we inherit from a standard container (such as std::vector)? If so what are the implications?
Show answer and explanation
Deriving from a standard container is legal syntax but usually the wrong public abstraction because containers are not polymorphic bases and lack virtual destructors. Composition preserves invariants and limits the exposed API.
Deriving from a standard container is legal syntax but usually the wrong public abstraction because containers are not polymorphic bases and lack virtual destructors. Composition preserves invariants and limits the exposed API.
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.