Question: 9.11 Lec14: Array of Objects 1. Create a class called LunchBox containing a dynamically growing list of food item names. Also, keep track of

9.11 Lec14: Array of Objects 1. Create a class called LunchBox containing a dynamically growing list of food1:Compare output Output is nearly correct, but whitespace differs. See highlights below. Special character

9.11 Lec14: Array of Objects 1. Create a class called LunchBox containing a dynamically growing list of food item names. Also, keep track of how many food items are in a lunch box. (Hint: dynamically increasing list of names can be implemented using a "string *"). 2. Create a default constructor that initializes the pointer variable to NULL and sets the count to zero. 3. Create a setter function setltem that takes a string as input, places it at the end of the list of food items in a lunch box, and increments the count by one. 4. Create an init function that inputs an integer the number of food items in a lunch box. This function creates the dynamic array of that many strings. 5. Release the dynamically allocated memory in the Destructor function. At this point, check with the instructor. 6. Take input in the following format: 2 //number of lunchboxes 1 //1 item in the first lunch box a //name of the first item 2 // 2 items in the 2nd lunch box b //first name of the item c //second name of the item 7. Display the names of food items in a lunchbox as a space-separated list. Food items from different lunch boxes should be printed on different lines. Expected output for the above input: a b c 511494.3152074.qx3zqy7 1:Compare output Output is nearly correct, but whitespace differs. See highlights below. Special character legend Input Your output Expected output 2:Compare output 2 DON D IN b 020 a a b c 0/1 0/1

Step by Step Solution

3.49 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The images depict a set of instructions for creating a class called LunchBox with certain features a... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!