Question

Create a class called Flower. Add one member variables color. Add only one getter function for the color. The get function returns color. Implement a constructor that expects color value and assigns it to the member variable. Create a subclass of Flower

Create a class called Flower. Add one member variables color. Add only one getter function for the color. The get function returns color. Implement a constructor that expects color value and assigns it to the member variable. 

Create a subclass of Flower named Rose. The Rose class has one member variable name.  Add a constructor which expects color and  name. Pass color to the base constructor and set name to it's member variable.

Write a program that has an array of  3 Flowers, and an array of 3 Roses. Feel free give the name and color to the flower as your choice. Use loops to print out the array properties to the terminal screen.

This is what I have so far


#include


using namespace std;


class Flower 

{

private:

string color;

public:

Flower();

void setColor(string color);

string getColor();

Flower(string color) 

{

this->color = color;

}

};


Flower::Flower()

{

}


class Rose : public Flower 

{

private:

string name;

public:

Rose();

Rose(string color, string name) : Flower(color)

{

this->color = color;

this->name = name;

}

};


Rose::Rose()

{

}


int main()

{

return 0;

}


void Flower::setColor(string color)

{

this->color = color;

}


string Flower::getColor()

{

return color;

}


0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Create a class called Flower. Add one member variables color. Add only one getter function for the color. The get function returns color. Implement a constructor that expects color value and assigns it to the member variable. Create a subclass of Flower
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT