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
Stacks and Queues are called data structures because their operations are specialized.
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.   SEE ATTACHED PHOTO FOR THE PROBLEM    #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();…
# Create an object from the Queue class. # Queue (with a capital Q) is the class name # queue (with a small q) is the object # created from the "Queue" class
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education