What is object slicing and how can we prevent it?

Answer Posted / prits

When an instance of derived class is assigned to base class
instance object slicing takes place.ie in this case the
derived portion gets truncated and only the base portion
remains.

The problem of object slicing can be prevented by the use
of pure virtual functions.

Is This Answer Correct ?    38 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does h mean in maths?

576


What is the maximum combined length of command line arguments including the space between adjacent arguments?

596


What would happen on forgetting [], while deallocating an array through new?

638


Explain about Virtual Function in C++?

613


Evaulate: 22%5 a) 2 b) 4 c) 0

672






Is c++ still being used?

568


What is the error in the code below and how should it be corrected?

313


How many standards of c++ are there?

630


What are the 2 main types of data structures?

590


What are the basics of local (auto) objects?

635


What is c++ best used for?

569


What is the full name of logo?

596


How can a struct in c++ differs from a struct in c?

614


List the special characteristics of constructor.

734


What is a constant? Explain with an example.

563