Can someone please help me with the following question? I'm stuck!
Consider the following class definition.
class Flower
{
private:
string color;
double cost;
public:
Flower()
{
color = “red”;
cost = 0.0;
}
Flower(string c)
{
color = c;
cost = 0.0;
}
void setColor(string c)
{
color = c;
}
void setCost(int amount)
{
cost = amount;
}
}
Which of the following is/are true?
(i) The attribute cost can be set to a new value, by a user
of this class
(ii) You can write cout<<”The flower is: “ << Flower.setColor();
(iii) A default constructor is provided.
(i) Does the cost data member have a scope type that makes it directly accessible from outside the class? Look at what scope-keyword is used for that data member and you have your answer.
(ii) Again, this boils down to the matter of scope - is this member function accessible from outside the class, a look at the scope keyword under which this function is defined should give you the answer.
(iii) Default constructors are constructors which take no arguments. Is that provided in the listing?