Vector subscript out of range

Hi I have an algorithm which try's to find the "maximum distance" between two nodes.

I have read each node from the file and that works. However, when the program try's to perform the MaxDist algorithm I get the vector subscript out of range error.

Here is the code for my algorithm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
        float tempDist;
	float currentMax;
	string node_1_name;
	string node_2_name;

	for (unsigned int i = 0; i < list_of_Nodes.capacity(); i++)
	{
		for (unsigned int k = i + 1; k < list_of_Nodes.capacity(); k++)
		{
			//Get the distance between two Nodes.
			tempDist = ArcLength(list_of_Nodes[i].getLat(), list_of_Nodes[i].getLong(), list_of_Nodes[k].getLat(), list_of_Nodes[k].getLong());

			//Get the names of the two Nodes.
			node_1_name = list_of_Nodes[i].getName();
			node_2_name = list_of_Nodes[k].getName();

			//Check to see if the currentMax if less or greather than the tempDist.
			if (tempDist > currentMax)
			{
				currentMax = tempDist;
			}
		}
	}
	return true;


If anyone could point out where I am going wrong that would be great.

Thanks in advance.
use .size(), not .capacity()
Topic archived. No new replies allowed.