Assume a class Window with accessor method getWidth that accepts no parameters and returns an integer . Assume further an array of 3 Window elements named winarr, has been declared and initialized . Write a sequence of statements that prints out the width of the widest window in the array .( this question is from myprograminglab)Thank you !!
1 2 3 4 5 6 7 8
|
int maxVal = winarr[0].getWidth();
for(int i = 1; i < WINARR_SIZE; i++)
{
if(winarr[i].getWidth() > maxVal)
maxVal = winarr[i].getWidth();
}
cout << "The widest width of the windows is: "
<< maxVal << endl;
| |
error:./CTest.cpp: In function ‘int main()’:
./CTest.cpp:14:21: error: ‘WINARR_SIZE’ was not declared in this scope
for(int i = 0; i < WINARR_SIZE; i++)
^
./CTest.cpp:16:31: error: ‘maxVal’ was not declared in this scope
if(winarr[i].getWidth() > maxVal)
^
./CTest.cpp:20:6: error: ‘maxVal’ was not declared in this scope
<< maxVal
^
./CTest.cpp:22:1: error: expected ‘;’ before ‘}’ token
}
error:./CTest.cpp: In function ‘int main()’:
./CTest.cpp:14:21: error: ‘WINARR_SIZE’ was not declared in this scope
for(int i = 0; i < WINARR_SIZE; i++)
^
./CTest.cpp:16:31: error: ‘maxVal’ was not declared in this scope
if(winarr[i].getWidth() > maxVal)
^
./CTest.cpp:20:6: error: ‘maxVal’ was not declared in this scope
<< maxVal
^
./CTest.cpp:22:1: error: expected ‘;’ before ‘}’ token
}