c++ - What is object slicing? -


someone mentioned in irc, google doesn't have answer.

"slicing" assign object of derived class instance of base class, thereby losing part of information - of "sliced" away.

for example,

class {    int foo; };  class b : public {    int bar; }; 

so object of type b has 2 data members, foo , bar.

then if write this:

b b;  a = b; 

then information in b member bar lost in a.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -