/* Since we changed the upper-left point of MyRectangle using SetUpperLeft, you think that the itsTop (aka upper) and itsLeft would have changed too, eh? I mean, really... Rectangle.itsLeft is SUPPOSED to always be the same value as Rectangle.itsUpperLeft.itsX, right? */

// However, the above code still prints out 100,20,50,80
// instead of 45,25,50,80

std::cout << "Upper Left X Coordinate: ";
std::cout << MyRectangle.GetUpperLeft().GetX();
// But yet, this still prints out what we know should be the correct setting (25)
int x;
std::cin>>x;
return 0;
}

/*#######################################*/

Any help would be appreciated.
Obviously we know that this code has a bug we just can't seem to find it.
/*######################################*/
OUTPUT:
Top:
100
Left:
20
Bottom:
50
Right:
80
Top:
100//see what it says after you changed the values
Left:
20
Bottom:
50
Right:
80
Upper Left X Coordinate: 25// but then look here

Last edited by incognito; 11-29-2001 at 03:54 PM.

There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

"...The only real game I thank in the world is baseball..." --Babe Ruth

"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.

Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

1. Move MyPoint.SetX(25); and MyPoint.SetY(45); out of the Recatangle constructor and after the declaration of MyPoint in main(). MyPoint can't be seen in the constructor and there is no reason for it to be there.

2. If you're going to use prefix the namespace for objects contained within it then endl should be std::endl.

You'll have to modify the SetUpper* and SetLower* functions call the relevent Set* function if you want the individual co-ordinates to change. However, I can see no point in storing the points individually aswell as in Point structures. You should choose one or the other, otherwise whenever one gets updated you'll have to call functions to modifiy the other.

You could scrap -

int itsTop;
int itsLeft;
int itsBottom;
int itsRight;

and just store all the co-ordinates in -

Point itsUpperLeft;
Point itsUpperRight;
Point itsLowerLeft;
Point itsLowerRight;