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 << "Animal sound" << std::endl; } }; class Dog : public Animal { public: void makeSound() { std::cout << "Woof" << std::endl; } }; int main() { Animal* a = new Dog(); a->makeSound(); // Calls Animal's makeSound delete a; return 0; }
More IT Operating System Questions
- To discard all pending data changes :
- Backtracking problem is seen in :
- What does the Hamming distance between two binary strings represent?
- What is a "smart object" in IoT?
- What does Polymorphism mean in the context of OOP?
- Which access specifier makes members accessible only within the class itself?
- What is the output of the following C program? #include int main() { int a=2, b=3, c=4; printf("%d", a<<1 | b&c); return 0; }
- Predict the output list1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5, 6, 7 ] print "list1[0]: ", list1[0]
- “Build Verification Testing” is the name of :
- In open addressing, if a collision occurs and the hash function h(key) maps to an occupied slot, which probing technique attempts to find the next availabl...
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)