Hmm, ok thanks. Here is the interface, we aren't given an implementation.
Code:
/******************************************************************************
Figure 1 -- Interface for type "String" (in file "String.h")
******************************************************************************/
#ifndef STRING_
#define STRING_
#include <iostream>
using namespace std;
class String
{
public:
// Capacity of a string
//
static const int MAX = 64;
// Construct empty string
//
String() { Length = 0; }
// Construct string using array of characters
//
String( const char Source[] );
// Return string length
//
unsigned length() const { return Length; }
// Return reference to element I
//
char& operator[]( unsigned I ) { return Mem[I]; }
const char& operator[]( unsigned I ) const { return Mem[I]; }
// Append string Source to the current string
//
String& operator+=( const String& Source );
// I/O operations
//
friend istream& operator>>( istream& Out, String& One );
friend ostream& operator<<( ostream& Out, const String& One );
private:
char Mem[MAX]; // Memory to hold characters in string
unsigned Length; // Number of characters in string
};
// Return string which is the concatenation of strings One and Two
//
String operator+( const String& One, const String& Two );
// Compare two strings (equality operator)
//
bool operator==( const String& One, const String& Two );
#endif