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

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -