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 is c++ and its features?

653


Write some differences between an external iterator and an internal iterator?

677


Can we make any program in c++ without using any header file and what is the shortest program in c++.

713


Difference between inline functions and macros?

673


Explain the difference between static and dynamic binding of functions?

652






What is a c++ object?

717


What is virtual base class?

665


List the types of polymorphism in c++?

726


What language is a dll written in?

620


What is a down cast?

687


Distinguish between a # include and #define.

754


What is the difference between a template and a macro?

670


Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list

707


what is the difference between overloading & overriding? give example.

670


How are pointers type-cast?

748