... function of the list class—enqueue calls insertAtBack (line 13), dequeue calls removeFromFront (line 18), isQueueEmpty calls isEmpty (line 23) and printQueue calls print (line 28). As with the Stack example in Fig. 19.13, this delegation requires explicit use of the this pointer in isQueueEmpty and printQueue to avoid compilation errors.

Fig. 19.16 Queue class-template definition.

Alternate View

1   // Fig. 19.16: Queue.h 
2   // Queue class-template definition. 
3   #ifndef QUEUE_H 
4   #define QUEUE_H 
5
6   #include "List.h" // List class definition 
7
8   template< typename QUEUETYPE >
9   class Queue : private List<QUEUETYPE> {
10   public: 
11      // enqueue ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.