Virtual table/dispatch table

It’s sometimes easier to understand with an example: class PureVirtual { public: virtual void methodA() = 0; virtual void methodB() = 0; }; class Base : public PureVirtual { public: virtual void methodA(); void methodC(); private: int x; }; class Derived : public Base { public: virtual void methodB(); private: int y; }; So, given … Read more

Difference between virtual and abstract methods [duplicate]

Virtual methods have an implementation and provide the derived classes with the option of overriding it. Abstract methods do not provide an implementation and force the derived classes to override the method. So, abstract methods have no actual code in them, and (non-abstract) subclasses HAVE TO override the method. Virtual methods can have code, which … Read more

How has CPU architecture evolution affected virtual function call performance?

AMD processor in the early-gigahertz era had a 40 cycle penalty every time you called a function Huh.. so large.. There is an “Indirect branch prediction” method, which helps to predict virtual function jump, IF there was the same indirect jump some time ago. There is still a penalty for first and mispredicted virt. function … Read more