Answered step by step
Verified Expert Solution
Question
1 Approved Answer
18. Given the following template class. Please code the add function and full function. (11 points) #ifndef BAG_H_ #define BAGH_ #include #define SIZE 20 using
18. Given the following template class. Please code the add function and full function. (11 points) #ifndef BAG_H_ #define BAGH_ #include #define SIZE 20 using namespace std; template class bag { public: bag(); //constructor bool add( T item); //add an item into bag bool remove(); //remove an item from bag bool empty(); //check if the bag is empty bool full(); //check if the bag is full int size(); //return size of bag int clear(); //clear the bag private: T arr[SIZE]; //storing items int counter; l/counting how many items in the bag }; #endif
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