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

class String {
public:
String (const char* s);
~String () { delete [] text; }// destructor
........
private:
char* text;
int len;
};
The ~String member function, specified completely above as "inline" code, releases the space pointed to by text.

Overloading Definition

In C++, two functions in the same scope may have the same name. When functions are overloaded this way, the C++ compiler determines which one is needed by examining the function's arguments. For example, suppose that two prototypes of the function fooexist in the same scope

void foo (int); void foo (double);

// now we are overloading

Now
foo (1);// generates a call to foo (int) foo (1.0);// generates a call to foo (double)

By this means functions which do the same operation, but with parameters of different type may use the same name. This cuts down on the number of names we need to create.

March 11, 1998

Page 6

C201/TAM