Question
DATA STRUCTURES & OTHER OBJECTS Using C++ Please provide header file[.h] , driver file,[.cpp] and main file [.cpp] Please provide your code and screenshot of
DATA STRUCTURES & OTHER OBJECTS Using C++
Please provide header file[.h] , driver file,[.cpp] and main file [.cpp]
Please provide your code and screenshot of how your code ran.
For this week's assignment you will implement astack and a queue, as discussed in class.
The stack and queue must be implemented as classes, with both a header and a cpp file
(i.e. something likemyReallyCoolStack.h, myReallyCoolStack.cpp, myqueue.h, myqueue.cpp)
You may use your sequence class implementation but that is not mandatory.
Both the stack and the queue must be implemented usingan array (i.e. do not use pointers).
The size of the array must be obtained from the user at run-timeand the array must be dynamically allocated using thenewoperator.
DO NOT FORGET to delete the array (return the memory to the heap) when the stack and queue are destroyed (using the destructor)
Look at the destructor in the InfraredSupport.h file included in the tar file sent in email
Add a print statement in both stack and queue class destructors saying that the array is being deleted
You must use value_type as the types of variables to be stored in the stack and queue (see the sequence assignment)
You should have one main test driver program, meaning only onesource file containingint main().
The main program must prompt the user for the size of an array
You will need toinstantiate objects of both your stack and your queue
Your main test drivermust populate (i.e. push(xxx) values intoboththe stack and the queue
Your main test driver must attempt to push more members into the stack and queue data structures than there is space available
Your data structures must guard against this
Your main test driver must pop() values from both data structures and print the output accordingly (in the proper stack or queue order)
Your main test driver must attempt to pop() more values than actually exist in both of the data structures
Your data structures must guard against this
Include the following test (If not I will have you add it so you may as well prepare for it now :-)
If your stack and queue are capable of holding 10 items (remember to use value_type),
Use a loop to push() 10 items into your data structures
After that loop has finished, attempt to push() at least one more item into each
Use a loop to pop() 10 items from your data structures
After that loop has finished, attempt to pop() at least one more item from each
Show the output from the destructors stating that the array has been deleted (from both data structures)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started