Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the c++ codde to define a base cass called Food that has 2 private variabl

ID: 3832191 • Letter: W

Question

Write the c++ codde to define a base cass called Food that has 2 private variables ( string shape, string color) with a derived class called Fruit. It will puplicly inherit the base class. In main, create a fruit object called Apple and set the shape to "round" and the color to "red". Create another Fruit object called Banana and set the shape to "special" and the color to "yellow".

Define the necessary accessor and mutator functions for the base class (in the class). In the main function, output the Apple's color and the Banana's shape.

Fill in the code

---------------------------------------------------------------------------------------------------------------------------

#include <iostream>

using namespace std;

class Food {

public:

//deafult constructor

Food() {};

// destructor

~Food() {};

// mutators

//accessors

private:

};

class Fruit : public Food {

public:

Fruit() {};

~Fruit() {};

private:

};

int main() {

return 0;

}

Explanation / Answer

#include <iostream>

using namespace std;

class Food {

public:

//deafult constructor

Food() {};

// destructor

~Food() {};

// mutators

//accessors

private:

};

class Fruit : public Food {

public:

Fruit() {};

~Fruit() {};

private:

};

int main() {

return 0;

}