Grant
Grant

Reputation: 143

Overriding Overloaded Functions in Inheritance

Text book extract:

Anytime we redefine an overloaded function name from the base class, all the other versions are automatically hidden in the derived class.

I get this. But, what is the reasoning behind this. Or is it like that's how they designed C++?

Upvotes: 1

Views: 53

Answers (1)

Mark B
Mark B

Reputation: 96241

It's to avoid accidentally providing access to/calling base class methods you don't intend to call. If you explicitly want to ALSO provide the base class methods the language provides that syntax with using Base::function_name;. Alternately if the functions are orthogonal in functionality, don't name them the same thing.

Upvotes: 1

Related Questions