Question

The following C++ code intends to demonstrate runtime polymorphism, but it's not working as expected. What is the issue? #include class Animal { public:     void makeSound() { // Problematic         std::cout

A The `makeSound()` method in `Animal` is not declared `virtual`.
B The `makeSound()` method in `Dog` is not declared `override`.
C `Dog` should not inherit from `Animal`.
D The `main` function should create a `Dog` object directly, not an `Animal` pointer.
E There is no issue; the code works as intended.
Practice Next

Hey! Ask a query