6
#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; } 
1

2 Answers 2

15
suzie.Person::sing(); 
Sign up to request clarification or add additional context in comments.

3 Comments

or Person& sue = suzie; sue.sing();.
or static_cast<Person&>(suzie).sing(); or any variation thereof, yes.
I wrote that and then removed it. I try to NEVER use a cast where an implicit conversion will work.
2

The child can use Person::sign().

See http://bobobobo.wordpress.com/2009/05/20/equivalent-of-keyword-base-in-c/ for a good explanation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.