Answers 857
D
- The following is one possible answer:
class boundedArray : public Array
{
//...
} - The following is one possible answer:
class Set : private Array
{
// ...
} - The following is one possible answer:
0: #include <iostream.h>
1: #include <string.h>
2:
3: class String
4: {
5: public:
6: // constructors
7: String();
8: String(const char const);
9: String(const String &);
10: ~String();
11:
12: // overloaded operators
13: char & operator[](int offset);
14: char operator[](int offset) const;
15: String operator+(const String&);
16: void operator+=(const String&);
17: String & operator= (const String &);
18: friend ostream& operator<<( ostream&
19: theStream,String& theString);
20: friend istream& operator>>( istream&
21: theStream,String& theString);
22: // General accessors
23: int GetLen()const { return itsLen; }
24: const char GetString() const { return itsString; }
25: // static int ConstructorCount;
26:
27: private:
28: String (int); // private constructor
29: char * itsString;
30: unsigned short itsLen;
31:
32: };
33:
34: ostream& operator<<( ostream& theStream,String& theString)
35: {
36: theStream << theString.GetString();
32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 857