Todos os livros

Profissional

Apps Sobre Coach Entrar Começar a ler

Computer Science · Glossário

O que é Object slicing?

Definition 3.2 University Computer Science — Year 2 · Capítulo 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.
Ler no capítulo →