Part C: Critical Analysis: (0.5 x 2 =1 point)1) What happens if the pointer is initially set to safe empty state or notinitialized at all and it is used to retrieve the data. Which option is safe to...

Part C: Critical Analysis: (0.5 x 2 =1 point)1) What happens if the pointer is initially set to safe empty state or notinitialized at all and it is used to retrieve the data. Which option is safe to doso? Explain your answer.2) Validations you have used (if any) and why?Part D: (10 points)struct Item {char m_name[20];int m_units;double m_price;};Using the structure “Item” above, complete the following class named Cart . Yourclass represents a set of Items.class Cart{//private data members;public://member functions;};The class hastwo attributes:
- m_item — a pointer to a dynamically allocated array of items.
OOP244S1A Page 4 of 13
- m_size — the number of items in the cart. a default constructor that sets the cart to a safe empty state a constructor with one parameter for number of items. This constructordynamically allocates an array of items to the number received through theparameter and keeps its address in the m_item pointer. A function “increaseUnits” to increase the number of units of an item in thecart. A function “decreaseUnits” to decrease the number of units of an item in thecart. A function to display the details of the cart including the item, its units, priceper unit and total cost of all units. Write the member functions to fulfill the following call in the client code.Cart ct;ct.increaseUnits(5).display().decreaseUnits(2).display();- If invalid data is received all of the above will set the object to a safe empty state.
Jun 27, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here