1 2 3 4 5 6 7 8 9 10 11 12

A couple of points. Why not text = NULL; (or text = 0) since we clearly want the null string in the overloaded function? No good reason, just a common practice.

Here we have formed the new String constructor called the default constructor, because it has no arguments, which will be invoked when String objects are declared without a specified value.
String S;// default constructor is invoked

In addition to function overloading, C++ also supports operator overloading, where the same operator serves two different purposes depending on the context.

cin >> N;

// in C >> is right-shift bitstring

In C++ the >> also represents an input operation, not a left shift operation on bit strings, as it does in C. Different purposes saves on the need to create more symbols.

There are more advanced examples that are useful in ADT applications, but we will leave these for now.

March 11, 1998

Page 8

C201/TAM