Overloaded Constructors

Constructors are one of the most common places to see function overloading. Overloading means there is more than one function body associated with the same name. Overloaded constructors are differentiated by the type signature, that is, the arguments used in the function call or declaration.

In the example there are three constructors. One used with no arguments, one with one argument, and one with two arguments. The number of arguments used in a declaration statement would indicate the constructor invoked.

[audio] [real] Text to accompany slide11, in Chapter 5 of An Introduction to Object-Oriented Programming