Question: (0) Suppose a C++ class is needed to represent a piece of fruit in a computer program. The class should be named Fruit and have

 (0) Suppose a C++ class is needed to represent a piece

(0) Suppose a C++ class is needed to represent a piece of fruit in a computer program. The class should be named Fruit and have two member variables for a grade (a single character) and name (a string). For example, the name might be Bananas and the grade might be A. Write a declaration for this class using the most suitable data types. Declare a default constructor and an initializing constructor (with one parameter for each member variable). The constructors should be available outside the class but the variables should not be. (ii) Write the prototype for a member function named regrade that changes the fruit's grade to a new grade that is passed into the function. It should have one parameter named new_grade. Use the most suitable return type for the function. You DO NOT have have to write the function itself. (ii) Show how you would declare a variable in the main function of the Fruit type using the initializing constructor to give it values for grade A pineapples. Then show how to call the regrade function to change the grade to B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!