home *** CD-ROM | disk | FTP | other *** search
- // "Friend Classes" -- FRIEND.HPP
- // This program illustrates friend classes
-
- #include <iostream.h>
-
- enum boolean { bFalse, bTrue };
-
- class Array
- {
- friend class fixedStack;
-
- public:
- Array();
- ~Array();
-
- void create(unsigned ArrSize);
-
- boolean insert(char x);
- boolean remove(char& x);
-
- void erase();
-
- protected:
- unsigned m_nWorkSize;
- unsigned m_nArrSize;
- char* m_pData;
- };
-
- class fixedStack // the class Array has befriended
- {
-
- public:
- fixedStack(unsigned MaxSize = 10);
- ~fixedStack();
-
- boolean isempty();
-
- void push(char x)
- { m_pArr->insert(x); }
- boolean pop(char& x)
- { return m_pArr->remove(x); }
- void clear()
- { m_pArr->m_nWorkSize = 0; }
-
- protected:
-
- Array* m_pArr;
- };
-
-
-