Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the code posted in the folder BagTemplatewithIterator on our D2L website. Be sure to document your work through code comments and a written summary

Use the code posted in the folder BagTemplatewithIterator on our D2L website. Be sure to document your work through code comments and a written summary of how your code works. Create a thorough test program for the functions and show your test results with your summary of the code. #include #include #include #include #include "node2.h" #include "bag5.h" using namespace std; // PROTOTYPE for a function used by this demonstration program template void get_items(bag& collection, SizeType n, MessageType description) // Postcondition: The string description has been written as a prompt to the // screen. Then n items have been read from cin and added to the collection. // Library facilities used: iostream, bag4.h { Item user_input; // An item typed by the program's user SizeType i; cout << "Please type " << n << " " << description; cout << ", separated by spaces. "; cout << "Press the key after the final entry: "; for (i = 1; i <= n; ++i) { cin >> user_input; collection.insert(user_input); } cout << endl; } int main() { //demostrate how to use set template class set actors1; set actors2; set result; set::iterator role; actors1.insert("moe"); actors1.insert("curly"); actors2.insert("larry"); actors2.insert("curly"); for(role = actors1.begin(); role != actors1.end(); ++role) cout<<*role<<" "; cout< *head_ptr = new node(); list_head_insert(head_ptr, 42); list_head_insert(head_ptr, 13); list_head_insert(head_ptr, 67); node_iterator start(head_ptr); node_iterator finish; node_iterator position; for(position = start; position != finish; ++position) cout<<*position<< " "; cout< bag_of_int; bag bag_of_string; bag_of_int.insert(3); bag_of_string.insert("hello"); bag_of_string.insert("goodbye"); bag_of_string.insert("auf wiedersehen"); bag_of_string.insert("goodbye"); bag_of_string.insert("hello"); bag_of_string.insert("goodbye"); cout << "count of goodbye: " << bag_of_string.count("goodbye") << endl; cout << "count of guten morgen: " << bag_of_string.count("guten morgen") << endl; cout << "count of 3: " << bag_of_int.count(3) << endl; for(bag::iterator cursor = bag_of_string.begin(); cursor != bag_of_string.end(); ++cursor) cout<<*cursor<< " "; cout<

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago