O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declaring Overloaded Member Functions in a Class

The idea of overloading is to use the same name for more than one function in a class.

This can be useful when you have separate names for functions that do essentially the same thing, but differ only in the number or types of arguments required. For instance, anExternalInterface has member functions DisplayText(), DisplayRequest(), and DisplayNumber(). Wouldn't it be nice to be able to just call a function named Display() and have the compiler figure out which implementation to call based on the arguments provided?

C++ makes this fairly simple.

For instance, to the compiler, the following declarations represent separate and distinguishable member functions of anExternalInterface, despite having ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required