Top "Virtual-functions" questions

In object-oriented programming, a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting class by a function with the same signature.

Does Swift have dynamic dispatch and virtual methods?

Coming form a C++/Java/C# background I was expecting to see virtual methods in Swift, however reading the swift …

virtual-functions swift dynamic-dispatch
Virtual Methods or Function Pointers

When implementing polymorphic behavior in C++ one can either use a pure virtual method or one can use function pointers (…

c++ function-pointers virtual-functions
Why I have to redeclare a virtual function while overriding [C++]

#include <iostream> using namespace std; class Duck { public: virtual void quack() = 0; }; class BigDuck : public Duck { public: // void quack(); (…

c++ virtual-functions
Performance of Expression.Compile vs Lambda, direct vs virtual calls

I'm curious how performant the Expression.Compile is versus lambda expression in the code and versus direct method usage, and …

c# performance lambda expression virtual-functions
Can virtual functions be constexpr?

Can virtual functions like X::f() in the following code struct X { constexpr virtual int f() const { return 0; } }; be constexpr?

c++ c++11 virtual-functions constexpr
in c++ when subclassing why sometimes need to add virtual keyword to overridden function?

Why do I sometimes see in C++ examples when talking about subclassing / inheritance, the base class has virtual keyword and …

c++ inheritance virtual-functions
why do we actually have virtual functions?

I am new to C++. Could anybody tell me the difference between method overriding and virtual function concepts in c++. …

c++ overriding virtual-functions redefinition
What is the first (int (*)(...))0 vtable entry in the output of g++ -fdump-class-hierarchy?

For this code: class B1{ public: virtual void f1() {} }; class D : public B1 { public: void f1() {} }; int main () { B1 *b1 = …

c++ gcc virtual-functions vtable
Performance hit of vtable lookup in C++

I'm evaluating to rewrite a piece of real-time software from C/assembly language to C++/assembly language (for reasons not …

c++ c real-time vtable virtual-functions
Member function templates cannot be declared virtual - From Addison Wesley: C++ Templates

From Addison Wesley: C++ Templates Member function templates cannot be declared virtual. This constraint is imposed because the usual implementation …

c++ templates virtual-functions