Define a class named CWeight that stores two integers as pounds and ounces. It has default and argument constructors, and has getter and setter functions to get and set pounds and ounces.
Overload the casting operator () that casts a CWeight object to a double as kilograms.
Overload the < operator that compares the weights of two CWeight objects.
Overload the >> operator to prompt and get input for pounds and ounces for a CWeight object. And overload the << operator to display an object in pounds and ounces.
Exercise the class in client code as follows:
1. Make an STL list of 20 CWeight objects with random values.
2. Display the list using the for_each algorithm.
3. Sort the list in ascending order according to weight values.
4. Display the sorted list using the for_each algorithm again.
5. Display the sorted weights in kilograms using the for_each algorithm again.
Format your output with proper alignment and blank lines, and describe the output so that it is understandable.
Submission:
Upload the cpp file to Canvas for grading. One single cpp file is preferred.
Rubric:
Define the class – 30
General – 10
op () – 5
op <, <<, >> – 15
Client: 30
List of 20 random weights – 10
Display using for_each – 8
Sort – 8
Display kilo – 4