the following is a program i need help with involvingclasses. any help will be g
ID: 3618375 • Letter: T
Question
the following is a program i need help with involvingclasses. any help will be greatly appreciated.Now you need to write a class WeightType to encapsulate poundsand ounces. Class WeightType has two instance data fields: poundsand ounces, both are integers. It has the following memberfunctions: WeightType (); //default construct, initialize both pounds and ounces to zero
WeightType (int lb, int oz); // twoarguments construct // initialize instance field pounds to lb, ounces to oz
~WeightType(); // destructor that destroys object when it is out of scope // don’t need put any code in it
void setWt (); // member function that prompt and read in pounds and ounces // from keyboard input
void printWt (); //displays the current weight instance // as: XX pounds XX ounces, where XX means numericalvalue
Exercise your WeightType class in main by calling each of theabove functions.
Note: Code the class member functions outside of class block; usescope resolution operator to bring the scope back to theclass. Indicate clearly in your code as comment, from where to whereis class definition, member function definition, and clientcode. the following is a program i need help with involvingclasses. any help will be greatly appreciated.
Now you need to write a class WeightType to encapsulate poundsand ounces. Class WeightType has two instance data fields: poundsand ounces, both are integers. It has the following memberfunctions: WeightType (); //default construct, initialize both pounds and ounces to zero
WeightType (int lb, int oz); // twoarguments construct // initialize instance field pounds to lb, ounces to oz
~WeightType(); // destructor that destroys object when it is out of scope // don’t need put any code in it
void setWt (); // member function that prompt and read in pounds and ounces // from keyboard input
void printWt (); //displays the current weight instance // as: XX pounds XX ounces, where XX means numericalvalue
Exercise your WeightType class in main by calling each of theabove functions.
Note: Code the class member functions outside of class block; usescope resolution operator to bring the scope back to theclass. Indicate clearly in your code as comment, from where to whereis class definition, member function definition, and clientcode.
Explanation / Answer
please rate - thanks #include #include using namespace std; class weightType {private: int lb; int oz; public: weightType() {lb=0; oz=0; } weightType(int l,int o) {lb=l; oz=o; } void setWt ( ) {cout lb; cout > oz; } void printWt() {coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.