Starting Out with C++: Early Objects
Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
Question
Book Icon
Chapter 18, Problem 6PC
Program Plan Intro

Dynamic String Queue

Program Plan:

  • Include the required header files.
  • Declare a class Dynque that creates a queue and store all the elements in the queue.
    • Declare all the variables present in the class.
    • Declare the front and rear pointers and the number of items.
    • Create a constructor to allocate elements in queue.
    • Create a destructor to deallocate elements in queue.
    • Create a function void Dynque<T>::enqueue(T val)that inserts the value in the variable val at the rear end of queue.
    • Create a function  void Dynque<T>::dequeue(T &val)that removes the value at the  front of the queue, and copies it into val.
    • Create a boolean function to check if queue is empty and a function clear to dequeue all elements present in the queue.
  • Declare the main function.
    • Prompt the user to enqueue 5 strings into the queue.
    • Dequeue and retrieve all items present in the queue.

Blurred answer
Students have asked these similar questions
C# language Write a program that creates a Queue or Stack (your choice) that represents a list of work orders. This program should use loop, allowing the user to push and pop items on the stack / queue. The program should also allow the user to print all the items in the stack / queue to the console.
c++ data structures ADT Unsorted List The specifications for the Unsorted List ADT states that the item to be deleted is in the list.   Rewrite the specifications for DeleteItem so that the list is unchanged if the item to be deleted is not in the list. Rewrite the specifications for DeleteItem so that all copies of the item to be deleted are removed if they exist
C++ ProgrammingActivity: Queue Linked List Explain the flow of the code not necessarily every line, as long as you explain what the important parts of the code do. The code is already correct, just explain the flow.   #include "queue.h" #include "linkedlist.h" class SLLQueue : public Queue {     LinkedList* list;      public:     SLLQueue() {             list = new LinkedList();     }     void enqueue(int e) {         list->addTail(e);         return;     }     int dequeue() {         int elem;         elem = list->removeHead();         return elem;     }     int first() {         int elem;         elem = list->get(1);         return elem;;     }     int size() {         return list->size();     }     bool isEmpty() {         return list->isEmpty();     }     int collect(int max) {         int sum = 0;         while(first() != 0) {             if(sum + first() <= max) {                 sum += first();                 dequeue();             } else {…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage