Question: C++ only Lets start with a simple task. You are making a very simple program to keep track of gold bars for a goldsmith. Make
C++ only
Lets start with a simple task. You are making a very simple program to keep track of gold bars for a goldsmith.
Make a class called GoldBar with the following data members or properties:
Weight (in grams)
Karats (integer value)
Price (in PKR)
You also need to make the following member functions:
Constructor function with three parameters corresponding to the three properties.
A destructor function.
Setters and getters for the three data members
Overload == operator so that it compares two objects of this class using the three properties (weight, karats, and price). If all three are equal then it returns true, false otherwise.
Overload < and > operators so it compares two objects of this class using their prices.
Overload += and -= operator so that the weight of the object can be incremented or decremented by an amount in grams given on the right-hand side of the respective operator.
Add appropriate code in the main function so that it can demonstrate the functions of the class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
