Tous les livres

Professionnel

Applis À propos Coach Connexion Commencer la lecture

Computer Science · Glossaire

Qu'est-ce que « Object slicing » ?

Definition 3.2 University Computer Science — Year 2 · Chapitre 3 — Inheritance and Polymorphism

Object slicing is the copy of a derived object into an object of its base class: by assignment, by initialisation, or by passing it by value to a parameter of the base type. Only the base part is copied, and the result is a plain base object; the derived members and the derived behaviour are lost.

Slicing. Copying a Recording into an Item copies the base part only. The copy is a genuine Item, whose table pointer () is that of Item, so even its virtual calls run Item’s functions.
Slicing. Copying a Recording into an Item copies the base part only. The copy is a genuine Item, whose table pointer (Section 3.2) is that of Item, so even its virtual calls run Item’s functions.
Lire dans le chapitre →