C++ | Inheritance | Question 6
Base *bp =
Derived *dp =
(A) No Compiler Error
(B) Compiler Error in line “Base *bp = new Derived;”
(C) Compiler Error in line ” Derived *dp = new Base;”
(D) Runtime Error
Explanation: A Base class pointer/reference can point/refer to a derived class object, but the other way is not possible.
Quiz of this Question
Want to learn from the best curated videos and practice problems, check out the C Foundation Course
for Basic to Advanced C.