2

C++ newbie here. Is there a way to call an overloaded function in a base class from the same function name with the same signature in a derived class? In Smalltalk, I can do it the "super" keyword. Is there any C++ equivalent?

class MyBaseClass {
  void initialize() { doSomething(); }
};

class MyDerivedClass : public MyBaseClass {
  void initialize() {
      super initialize(); // first, call MyBaseClass::initialize()
      doLocalInitialize(); // now initialize non-inherited members
}

Thanks, Norm

Norm G
  • 21
  • 3

1 Answers1

1

You literally said the correct syntax in your comment :)

class MyBaseClass {
    void initialize() { doSomething(); }
};

class MyDerivedClass : public MyBaseClass {
void initialize() {
    MyBaseClass::initialize(); // first, call MyBaseClass::initialize()
    doLocalInitialize(); // now initialize non-inherited members
}
RyanP
  • 1,898
  • 15
  • 20