Check out example codes for "object slicing in c++". It will help you in understanding the concepts better.

Code Example 1

class Base { int x, y; }; 
class Derived : public Base { int z, w; }; 
int main()  
    Derived d; 
    Base b = d; // Object Slicing,  z and w of d are sliced off 
# This can be prevented by using pointers.

Learn ReactJs, React Native from