Provide the Mystack.h and Myqueue.h in different steps, Stacks and queues are important data structures in the
Fantastic news! We've Found the answer you've been seeking!
Question:
Provide the Mystack.h and Myqueue.h in different steps,
Transcribed Image Text:
Stacks and queues are important data structures in the fields of digital design and computer architecture. Your task is to write two template classes for managing generic stacks and queues, based on the following requirements: • Create and submit the files MyStack.h and MyQueue.h (remember that .cpp files are not allowed when defining templates). Ensure that the MyStack and MyQueue classes work properly with the int, float, and char datatypes. • The maximum size of the stack or queue shall be hardcoded as 10. • Each class should provide the following public member functions: o default constructor o peek: non-destructively returns the value on top of the stack or at the front of the queue. An exception handler should return an arbitrary value and print an error message if the container is empty. pop: remove one element from container and return it push: insert new element into container o clear: delete all entries from container o size: number of elements in container o full: returns true if the container is full o empty: returns true if the container is empty • Overflow and underflow must be handled via exceptions. The grader will compile your classes with a main.cpp file to grade functionality. This main.cpp file: #include <iostream> #include <iostream> #include "MyStack.h" #include "MyQueue.h" using namespace std; int main() { MyStack <int> 31; MyQueue <int> ql; int i; cout << "Filling stack and queue." << endl; for (i=0; i<11; i++) { s1.push(i); ql.push(i); Stacks and queues are important data structures in the fields of digital design and computer architecture. Your task is to write two template classes for managing generic stacks and queues, based on the following requirements: • Create and submit the files MyStack.h and MyQueue.h (remember that .cpp files are not allowed when defining templates). Ensure that the MyStack and MyQueue classes work properly with the int, float, and char datatypes. • The maximum size of the stack or queue shall be hardcoded as 10. • Each class should provide the following public member functions: o default constructor o peek: non-destructively returns the value on top of the stack or at the front of the queue. An exception handler should return an arbitrary value and print an error message if the container is empty. pop: remove one element from container and return it push: insert new element into container o clear: delete all entries from container o size: number of elements in container o full: returns true if the container is full o empty: returns true if the container is empty • Overflow and underflow must be handled via exceptions. The grader will compile your classes with a main.cpp file to grade functionality. This main.cpp file: #include <iostream> #include <iostream> #include "MyStack.h" #include "MyQueue.h" using namespace std; int main() { MyStack <int> 31; MyQueue <int> ql; int i; cout << "Filling stack and queue." << endl; for (i=0; i<11; i++) { s1.push(i); ql.push(i);
Expert Answer:
Answer rating: 100% (QA)
MyStackh The code for the above is include include template class MyStack private T stack10 int ... View the full answer
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these operating system questions
-
You are a supervisor at your company. You've overheard Employee A making offensive comments to other employees, and Employee B has complained about these comments. You've given Employee A a verbal...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Hyten Corporation On June 5, 1998, a meeting was held at Hyten Corporation, between Bill Knapp, Director of Marketing/Sales, and John Rich, director of engineering. The purpose of the meeting was to...
-
What other cost factors might you include in such an economic analysis? The proposed small office building in Example 3-2 has 24,000 net square feet of area heated by a natural gas furnace. The owner...
-
Compare the use of networking sockets with the use of shared memory as a mechanism for communicating data between processes on a single computer. What are the advantages of each method? When might...
-
Campbell's tax return was audited because she failed to report interest she earned on her tax return. What IRS audit selection method identified her tax return?
-
The ratio of sudden load to equivalent static load is. (a) 3 (b) 2 (c) 1.5 (d) \(\quad 1 / 2\)
-
Depletion ComputationsMinerals At the beginning of 2010, Callaway Company acquired a mine for $850,000. Of this amount, $100,000 was ascribed to the land value and the remaining portion to the...
-
2. Define "perfect competition" and "monopoly." Besides wheat, list three other products or services that have markets like perfect competition. List three products or services that have markets like...
-
1. Are Kellermans calculations correct? These are the first items to verify. 2. Take a close look at the data using appropriate statistical methods. 3. Are Kellermans conclusions correct? If so, why...
-
OLNEY COMPANY, INC. Insurance Deduction Register Name GRP. INS. HEALTH INS. CK. NO. Mangino, R. $0.85 $1.65 313 Flores, I. 0.85 1.65 314 Palmetto, C. 1.65 315 Waters, R. 0.85 1.65 316 Kroll, C. 0.85...
-
XYZ Corporation had following transactions: a. On January 4, 2020, it offered 25,000 ordinary shares were issued with a par value of $1 and market price of $50 each. (5 marks) b. On June 1, it...
-
Below are Royal Caribbean's cash flows from its most recent 10-K. Based on these, are you concerned about the company's operating cash flows, and if so, why? 2021 2020 2019 Net cash (used in)...
-
International Tennis (IT) is a vertically integrated full-service tennis corporation. It produces tennis equipment, including nets, lights, balls, and racquets under the IT brand, selling them in the...
-
Solve the following Cauchy-Euler differential equations: (a) 4ry' + 4ry - y = 0. (b) ry" + 10xy' + 8y = 0. (c) ry" - 6y = 0. (2) Solve the Cauchy-Euler DE by variation of parameters method: (a) xy" -...
-
The link length of the two-links robot is 1.0 m and 0.6 m, respectively. (a) if Angle 0=45 0-60. Find the Jacobin written in frame {0}; (b) Find the singular points in term of joint variables; (c)...
-
Assume that it is June, and a framer expects to harvest at least 10,000 bushels of soybeans during September. In June, the cash price for new-crop soybeans is $6 per bushel and the price of November...
-
Using thermodynamic data from Appendix 4, calculate G at 258C for the process: 2SO 2 (g) + O 2 (g) 88n 2SO 3 (g) where all gases are at 1.00 atm pressure. Also calculate DG8 at 258C for this same...
-
What is removed when a relation is converted from 2NF to 3NF?
-
What are the trade-offs involved in deciding how far data streams should be exploded?
-
Sludges Auto (refer to Chapter 12) is as an auto parts recycling center, using Ajax on Web sites for customers to browse for parts. Ajax allows the Web site to obtain data from the server while the...
-
Consider the flow of a perfect gas along a Fanno line. Show that the pressure at the * reference state is given by the relation 1/2 m 2RT, P Ayge(y+1)
-
Air flows in an 8-cm-inside diameter pipe that is \(4 \mathrm{~m}\) long. The air enters with a Mach number of 0.45 and a temperature of \(300 \mathrm{~K}\). (a) What friction factor would cause...
-
Air enters a duct with a mass flow rate of \(35 \mathrm{lbm} / \mathrm{sec}\) at \(T_{1}=520^{\circ} \mathrm{R}\) and \(p_{1}=20 \mathrm{psia}\). The duct is square and has an area of \(0.64...
Never Cry Wolf Authors Adventures With A Family Of Wolves 1st Edition - ISBN: B0099KZAFW - Free Book
Study smarter with the SolutionInn App