Mega Code Archive
Default values in member functions
#include
class Rectangle
{
public:
Rectangle(int width, int height);
~Rectangle(){}
void display(int aWidth, int aHeight,
bool UseCurrentVals = false) const;
private:
int itsWidth;
int itsHeight;
};
Rectangle::Rectangle(int width, int height): itsWidth(width), itsHeight(height
) {}
void Rectangle::display(int width, int height, bool UseCurrentValue) const
{
int printWidth;
int printHeight;
if (UseCurrentValue == true)
{
printWidth = itsWidth;
printHeight = itsHeight;
}
else
{
printWidth = width;
printHeight = height;
}
for (int i = 0; i