Why is my derived class not overriding the base class method in C++20?
I'm maintaining legacy code that I'm sure I'm missing something obvious here, but I've looked through the documentation and I'm still confused about This might be a silly question, but I'm working with an scenario where my derived class seems to ignore the overridden method from the base class. I have the following setup: ```cpp #include <iostream> class Base { public: virtual void show() { std::cout << "Base class" << std::endl; } }; class Derived : public Base { public: void show() override { std::cout << "Derived class" << std::endl; } }; int main() { Base* b = new Derived(); b->show(); // Expected to call Derived::show() delete b; } ``` When I run this code, I expect to see "Derived class" printed to the console, but instead, I'm seeing "Base class". I've ensured that I included the `override` keyword in the derived class. I've also tried to simplify my code, but the question continues. I compiled this using g++ version 10.2 with C++20 standard enabled. I checked if there was any scenario related to polymorphism and virtual functions, but everything seems correct according to the C++20 standards. Could there be a mistake I'm overlooking with respect to object slicing or something similar? I would appreciate any guidance on what might be happening here. Any help would be greatly appreciated! This is part of a larger service I'm building. I'm coming from a different tech stack and learning C++. Any ideas how to fix this?