Track Local Max and Min Values for X and Y

will this code work?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void Box::setMoreData() //track local max and min values for X and Y
{
	for (int j=0;j<4;j++) // 4 x Coords
	{
		if (xcoords[3] > xcoords[4])
		{
			local_maxx = xcoords[3];
			xcoords[3] = xcoords[4];
			xcoords[4] = local_maxx;
		}
		if (ycoords[3] > ycoords[4])
		{
			local_maxy = ycoords[3];
			ycoords[3]= ycoords[4];
			ycoords[4] = local_maxy;
		}
		if (xcoords[3] < xcoords[4])
		{
			local_minx = xcoords[3];
			xcoords[3] = xcoords[4];
			xcoords[4] = local_minx;
		}
		if (ycoords[3] < ycoords[4])
		{
			local_miny = ycoords[3];
			ycoords[3]= ycoords[4];
			ycoords[4] = local_miny;
		}
	}
}
how can i compare the max and min values for x and y across five box objects? i've tried creating a vector in a new class but i don't know how to populate them with the local max's and min's for each box object. I am having trouble first comparing the data locally. I think if I can first get that right I can then create a new object using that data with member functions to work on that data but i think my sorting is still wrong.
Ok, a third thread on the same topic Sigh

You still don't see that you are making life hard for yourself by storing all 4 points for the box, instead of 2 like multiple people have said. Just have a bottom left point and a top right point.

I am inclined not to post any more replies until you take notice of what is being said to you. Mark 2 of these threads as solved and direct others to the other one. And pay attention to what we are saying.
so int xcoords[2] and int ycoords[2]?
sorry nvm.
Topic archived. No new replies allowed.