Can I override virtual methods when sub-classing (inheriting) the class?

Yes. You surely can, otherwise you won’t be able sub-class the original C++ class at all. The virtual methods of the C++ class are implemented as C# virtual methods, you can override them from your deriving C# class. Due to the limitation of C# language itself, multiple inheritance is not supported.

Overriding virtual methods from C# does have cost, the C# wrapper class of the original C++ class will have to set up the native virtual function table and all the C# virtual methods to make it work. So overriding virtual method is not enabled by default, but it can be enabled programmatically from your code of the deriving C# class of the C# wrapper class.

← Faqs
Translate »