Explain Object Slicing and how it occurs when passing objects by value in an inheritance hierarchy.

Last updated 21 June 2026

  • Object slicing: copying a derived object into a base object by value keeps only the base part, dropping derived data and dynamic type.

  • After slicing, even virtual calls run the base version, because the base copy constructor knows nothing of the derived part.

  • Avoid it by passing and storing polymorphic objects by reference (const Base&) or pointer (including smart pointers).

  • https://utkrusht.ai/blog/cplusplus-interview-questions
  • https://roadmap.sh/questions/cpp
  • https://internshala.com/blog/cpp-coding-interview-questions/
All C++ interview questions