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.

Why C# implements methods as non-virtual by default?

Unlike Java, why does C# treat methods as non-virtual functions by default? Is it more likely to be a performance …

c# java .net virtual-functions
How do I denote a pure virtual function in a UML class diagram?

I am a student learning C++. I am creating a UML class diagram for my program that involves inheritance and …

c++ uml class-diagram virtual-functions pure-virtual
Why would a virtual function be private?

I just spotted this in some code: class Foo { [...] private: virtual void Bar() = 0; [...] } Does this have any purpose? (I am …

c++ private virtual-functions access-specifier overriding
gcc Woverloaded-virtual warnings

The following C++ code i think is correct, but produce some warnings when compiled with "-Woverloaded-virtual", is the warning bogus …

c++ gcc virtual-functions overloading
Why does this virtual destructor trigger an unresolved external?

Consider the following: In X.h: class X { X(); virtual ~X(); }; X.cpp: #include "X.h" X::X() {} Try to …

c++ destructor unresolved-external virtual-functions
overriding virtual function return type differs and is not covariant

Ah, SO came back just in time. I am getting a strange error: 'B::blah': overriding virtual function return type …

c++ covariance virtual-functions return-type object-slicing
Arduino C++ code: can you use virtual functions and exceptions?

Following up on this comment from the question Writing firmware: assembly or high level?: When compiling C++ code for the …

c++ arduino virtual-functions firmware
Force all classes to implement / override a 'pure virtual' method in multi-level inheritance hierarchy

In C++ why the pure virtual method mandates its compulsory overriding only to its immediate children (for object creation), but …

c++ overriding language-lawyer class-hierarchy virtual-functions
Calling Pure Virtual Function From Abstract Base Class Member Function?

So, based on a cursory search, I already know that calling a virtual function (pure or otherwise) from a constructor …

c++ inheritance virtual-functions pure-virtual
overriding protected internal with protected!

This is an extension for this question asked an hour ago. We cannot modify the access modifiers, when overriding a …

c# virtual-functions