What happens when a derived object is copied into a base class object?
-
A
The derived part is sliced away
Correct answer
-
B
The base part is discarded
-
C
The copy keeps both dynamic parts
-
D
The compiler rejects the copy
Correct answer
A. The derived part is sliced away
14 views
Explanation
Only the base subobject is copied, an effect known as object slicing.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is A? Ask here and get an explanation.
Ask a doubt about this MCQ