Question: Make a class called LunchBox containing a dynamically growing list of food item names. Also, keep track of how many food items are in a
Make 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.
Write a default constructor that initializes the pointer variable to NULL and sets the count to zero.
Use a setter function setItem 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.
Use a getter function string getItem that takes an index (integer) as input and returns the index-th food item's name.
Make a constructor that takes the number of food items in a lunch box and creates the dynamic array of hold food item names.
Release the dynamically allocated memory using a Destructor function.
Write a function display(LunchBox lbox) to print information in the lbox object. The display function should not be declared in the LunchBox class.
Take the following as input:
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 - Display the names of food items in each 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 Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
