Slicing happens when an object from a derived type is cast to an object of one of its base classes. When this happens, the new object will not have
the data member variables specific to the derived type.
The following example illustrates the unintended loss of information.
struct PartData {
int uuid;
std::string manufacturer;
};
// Use inheritance to share common data definitions.
struct TireData : PartData {
Color color;
TireType type;
};
void orderBike(TireData tire, ...) {
std::vector<PartData> parts;
// Noncompliant: the vector does not store the tire color and type.
parts.push_back(tire);
// ...
}