Question: Define a class named Fluid with two integer data members, gallons and pints. ( a ) Write a constructor for the class, Each data member
Define a class named Fluid with two integer data members, gallons and pints.
a Write a constructor for the class, Each data member defaults to
b Write set and get functions for both data members. Your set functions should make sure that gallons is greater than or equal to and pints is greater than and less than
Your set functions should allow cascaded calls. For example: if x is an object of the class, xsetGallonssetPints should be enabled.
c Overload the and operators to input and output a Fluidobject in a format such as gapnt
d Overload the operator to enable addition of two Fluid objects. Note that pints must remain between and
eg Assume that there are two Fluid objects a and b a is gallons and pints and b is gallons and pints. The operation should return a fluid object with gallons and pint instead of gallons and pints. There are pints in a gallon.
e Provide a conversion operator function that converts a Fluid object to an integer. eg If a is gallons and pints, then staticcastsinta will return
discard the pints part
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
