Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Code Using the listType code from Chapter 13 of your text as a guide, create a template class bagType which may be filled with

C++ Code

Using the listType code from Chapter 13 of your text as a guide, create a template class bagType which may be filled with any one of the standard data types including, as a minimum, integers, floats, characters, and strings. Your class should include function templates to

print the contents of a bag

display the total capacity of a bag

display the number of items currently in the bag

determine if the bag is empty

determine if the bag is full

Write a driver program to test your class and functions. Your driver program should include code to create a bag object that holds each of the types noted above and performs each of the functions for each type of bag.

Your main program should also implement exception handling using try and catch blocks as described in Chapter 14 of your text.

Do not use exception handling to ensure the user input matches the type requested. If you want to include that in your program use the logic that we have used previously to implement it (a while loop). For the purposes of this program, your bag should only accept positive values for the numeric types and only upper case values for the bag of characters. You do not need to write exception handling code for your bag of strings. Your code should include hard-coded input that tests the exception handling as well as code that generates correct input.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago