// // p.305 // Goal: with circular // #include using namespace std; struct NodeType { int info; NodeType* next; }; class QueType { NodeType* rear; public: QueType() // p.303 { rear = NULL; } void MakeEmpty() { // use rear; if ( rear != NULL ) { NodeType* t1 = rear->next; NodeType* t2 = rear->next; while( t1 !=rear ) { t1 = t1->next; delete t2; } delete rear; rear = NULL; } } ~QueType() { MakeEmpty(); } void Enqueue(int newItem) // p.304 { // go here } void Dequeue(int& item) { // go here } void Print() const { // go here NodeType* temp = rear->next; while(temp != rear) { cout << temp->info << " "; temp = temp->next; } cout << rear->info << " "; cout << "\n"; } }; void menu(); int main() { QueType me; int item; char ch; menu(); cin >> ch; while(tolower(ch) != 'q') { cout << "Do something!\n"; menu(); cin >> ch; } cout << "\n\nDone.\n\n"; return 0; } void menu() { cout << "\n\n Queue with Circular List\n"; cout << "===============================\n"; cout << "E Enqueue an item.\n"; cout << "D Dequeue.\n"; cout << "P Print.\n"; cout << "Q Quit.\n"; cout << "===============================\n"; cout << "Your selection: "; }