Semua buku

Profesional

Aplikasi Tentang Pelatih Masuk Mulai membaca

Computer Science · Glosarium

Apa itu Object slicing?

Definition 3.2 University Computer Science — Year 2 · Bab 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.
Baca dalam konteks →