Inheritance: Copying and slicing
'Real object-oriented programming' relies on reference semantics (use of pointers or C++ references to objects) rather than value semantics (copying of objects)
- In the example programs: The class B is derived from class A
- We copy an instance of B to a variable of type A
- No pointer types or reference types are involved
- The B part of the object is lost
- We say that it is sliced
Illustration of object slicing.
Does this variant change the game.
Slicing an object during parameter passing.