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 .
my program can not be run and they tell me to use if statment??
Thank you very much, the hw due tomorrow , emergency help plz!!
1 2 3 4 5
for(int i = 0; i < WINARR_SIZE; i++)
getWidth = min(getWidth, winarr[i].getSize());
cout << "The smallest width of the windows is: "
<< getWidth << endl;
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;