How can I call a base class method from a derived class if the derived class has a method with the same name?

this is what i want to do: (pseudo code)

class DerivedClass : public BaseClass { public Draw() { BaseClass.Draw() } } class BaseClass { protected Draw(); } 

Both figures have the same name and the same signature. The reason for this is because sometimes I want my derived classes to have a drawing function that just calls the base classes to draw, but in other cases I want the derived class to choose when to call the base drawing function or not. This meant that I could save the class, which I create derived classes in a much cleaner way, and I could just draw everything on them at all times. Derived classes themselves handle nitty-gritty.

What is the syntax for the BaseClass.Draw part? I thought you could just write it as it is, but the compiler complains, and I don't like that I can just call Draw because the signatures are the same.

+4
source share
2 answers

Syntax BaseClass::Draw() .

+8
source

Syntax

 DeriveClass::Draw() { BaseClass::Draw(); } 
+3
source

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


All Articles