Question: Create a class named Item that has a double data member cost. The class also has a static int data member number. This static data
Create a class named Item that has a double data member cost. The class also has a static int data member number. This static data member records how many Item objects were created. It should be initialized to Whenever a new object is created, number should be incremented by Your class should provide the following:
a A constructor cost defaults to Note: the cost should be at least
b A destructor that decrements number by and prints An Item has been destroyed".
c A set and a get function for the data member cost.
d A static member function getNumber that returns the value of number.
e A toString member function that returns the string representation of an tem object. eg Assume that there is an Item object with the data member cost xtoString should return $
Write a main function to test the class.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
