Working with Advanced Functions 293
10
35: int printWidth;
36: int printHeight;
37:
38: if (UseCurrentValue == true)
39: {
40: printWidth = itsWidth; // use current class values
41: printHeight = itsHeight;
42: }
43: else
44: {
45: printWidth = width; // use parameter values
46: printHeight = height;
47: }
48:
49:
50: for (int i = 0; i<printHeight; i++)
51: {
52: for (int j = 0; j< printWidth; j++)
53: {
54: cout << “*”;
55: }
56: cout << endl;
57: }
58: }
59:
60: // Driver program to demonstrate overloaded functions
61: int main()
62: {
63: // initialize a rectangle to 30,5
64: Rectangle theRect(30,5);
65: cout << “DrawShape(0,0,true)...” << endl;
66: theRect.DrawShape(0,0,true);
67: cout <<”DrawShape(40,2)...” << endl;
68: theRect.DrawShape(40,2);
69: return 0;
70: }
DrawShape(0,0,true)...
******************************
******************************
******************************
******************************
******************************
DrawShape(40,2)...
************************************************************
************************************************************
OUTPUT
LISTING10.2 continued