- Part 1 5 Pts Write Out The Class Specification Declaration That Is The Contents Of The Header File Inventory H Fo 1 (40.35 KiB) Viewed 69 times
Part 1 [5 pts]: Write out the class specification (declaration) that is the contents of the header file (Inventory.h) fo
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Part 1 [5 pts]: Write out the class specification (declaration) that is the contents of the header file (Inventory.h) fo
Part 1 [5 pts]: Write out the class specification (declaration) that is the contents of the header file (Inventory.h) for an Inventory class which contains data members: name, quantity, and, cost (this is the per unit cost). Make sure the specification contains the following: • a default constructor • an overloaded constructor that takes name, quantity, and cost as parameters • Accessor or getter functions for name, quantity, and cost • Mutator or setter functions for name, quantity, and cost • a calculateTotal() function that calculates the total cost as quantity cost. * Part 2 (10 pts]: Assume that the Inventory class implementation (Inventory.cpp) exists based on the specification in Part 1. In main() 1. Declare a pointer to an Inventory object called inv. 2. Create an array of dynamically allocated (that is, memory allocated on the heap) Inventory objects of size 3 and make inv point to the start of the array and initialize the elements with name, quantity and cost as follows: o "hammer" 100,5.97 "saw", 39, 13.98 "clamps". 23, 51.97 3. Write code to display the total cost of each object in the inv array (use the pointer operator).