C++ Sequence of Statements

Assume a class Window with accessor methods getWidth that accepts no parameters and return 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 code that doesn't work:

1
2
3
4
5
 for(int i = 0; i < WINARR_SIZE; i++) 
smallestWidth = min(smallestWidth, winarr[i].getSize()); 

cout << "The smallest width of the windows is: "
	<< smallestWidth << endl;


Hints from the lab:
You almost certainly should be using: getWidth
⇒ We think you might want to consider using: if
⇒ We think you might want to consider using: { }
an array of 3 Window elements

Your code does use WINARR_SIZE, but does not show how it was defined.

You use getSize(), but instructions mention getWidth().

prints out the width of the widest window

Your code seems to look for the smallest.


The big issue: How was the smallestWidth declared and initialized?
Topic archived. No new replies allowed.