Adam
0
Q:

object slicing in c++

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.
3

New to Communities?

Join the community