¿What's the C++ equivalent to Object Pascal Inherited()?

Hello,

I've a C++ virtual function and I need to override it and add my code without losing original functionality. In Object Pascal I can do it by using inherited([method parameters]). How can I do it in C++?

Note: The function is an event called by its class. So I cannot create a new function and call each function one after another. I need my code to executes inside the event right after the original code.

Thank you for read.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class A
  {
  public:
    virtual void foo()
      {
      cout << "A's foo\n";
      }
  };

class B: public A
  {
  public:
    void foo()
      {
      cout << "B's foo, calling A's foo\n";
      A::foo();
      cout << "B's foo again\n";
      }
  };


Hope this helps.
Topic archived. No new replies allowed.