Wie kann eine Unterklasse Aufruf einer Methode der Superklasse, die mit der gleichen Methode name der Unterklasse?

#include <iostream>
using namespace std;

class Person {
public:
    void sing();
};

class Child : public Person {
public:
    void sing();
};

Person::sing() {
    cout << "Raindrops keep falling on my head..." << endl;
}

Child::sing() {
    cout << "London bridge is falling down..." << endl;
}

int main() {
    Child suzie;
    suzie.sing(); //I want to know how I can call the Person's method of sing here!

    return 0;
}

InformationsquelleAutor Rick | 2011-06-09

Schreibe einen Kommentar