How to call a method of an overridden base class using C ++ / CLI

What is the correct way to implement this C # code:

protected override void SomeMethod(inputs) { ... do stuff .. base.SomeMethod(inputs); } 

in C ++ / CLI

+4
source share
1 answer

Qualifying the method name with the name of the base class.

 void SomeMethod(inputs) { ... do stuff .. base::SomeMethod(inputs); } 

Online Demo:

 #include<iostream> class Base { public: virtual void doSomething() { std::cout<<"In Base"; } }; class Derived:public Base { public: virtual void doSomething() { std::cout<<"In Derived"; Base::doSomething(); } }; int main() { Base *ptr = new Derived; ptr->doSomething(); return 0; } 
+8
source

Source: https://habr.com/ru/post/1388249/


All Articles