It is mentioned in C++ FAQ site -- \"larger derived class objects get sliced when passed by value as a base class object\", what does slicing mean? Any sample to demonstrate
struct A {
};
struct B : public A {
int x;
};
void f( A a ) {
// in here you can't access any of B's members - they have ben sliced
}
int main() {
B b;
f( b ); // slice!
}