158 Introduction to C++ Programming and Graphics
q = valueq;
w = valuew;
...
e = valuee;
}
where “valueq”, “valuesw”, etc., are specified values or names that describe
an object of the fruit class.
The implementation of the default fruit destructor reads:
fruit::~fruit()
{
delete q;
delete w;
...
delete e;
}
In this case,q, w, ..., eare introduced as pointers.
The implementation of the non-intrusivereadcolorfunction reads:
string fruit::readcolor(a, b, ..., c) const
{
...
return color;
}
The dots between the angular brackets denote various operations. The prefix
stringindicates that, after operating on a member, the functionreadcolor
will return the stringcolor, which can be evaluated as “red”, “green”, or any
other appropriate shade.
The implementation of the mutatorchangefunction is:
void fruit::change(g, o, ..., x)
{
...
}
The prefix “void” indicates that, when operating on a member, the function
“change” acts quietly and returns nothing.
The class implementation may be included in the class declaration either
partially or entirely. For example, the fruit class may be defined and imple-
mented as: