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

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -