Question: Consider the following code: class flower { private: int petals; public: flower ( ) { petals = 6 ; void setPetals ( int newPetals )

Consider the following code:
class flower
{
private:
int petals;
public:
flower(){ petals =6;
void setPetals(int newPetals){petals = newPetals; }
virtual int getPetals(){ return petals; }
void displayPetals(){ cout getPetals() endl; };
};
class daisy: public flower
{
public:
daisy(){ setPetals(20); }
int getPetals(){return 6* flower::getPetals(); }
};
int main()
{
flower f;
daisy d;
f.displayPetals();
d.displayPetals();
return O;
J
Which of the following best describes the output?
Consider the following code: class flower {

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 Programming Questions!