|
|
 |
|
|
|
|
26:
27: #if DEBUGLEVEL < HIGH
28: #define PRINT(x)
29: #else
30: #define PRINT(x) \
31: cout << x << end1;
32: #endif
33:
34:
35: class String
36: {
37: public:
38: // constructors
39: String();
40: String(const char *const);
41: String(const String &);
42: ~String();
43:
44: char & operator[](int offset);
45: char operator[](int offset) const;
46:
47: String & operator= (const String &);
48: int GetLen()const { return itsLen; }
49: const char * GetString() const
50: { return itsString; }
51: bool Invariants() const;
52:
53: private:
54: String (int); // private constructor
55: char * itsString;
56: unsigned short itsLen;
57: };
58:
59: bool String::Invariants() const
60: {
61: PRINT((String Invariants Checked));
62: return ( (bool) (itsLen && itsString) ¦¦
63: (!itsLen && !itsString) );
64: }
65:
66: class Animal
67: {
68: public:
69: Animal():itsAge(1),itsName(John Q. Animal)
70: {ASSERT(Invariants());}
71:
72: Animal(int, const String&); |
|
|
|
 |
|
|
|
|
continues |
|
|
|
|
|