Error accessing value in pairs vector

I have a vector of pairs as a field inside an object. The mentioned object has a method when I need to access the values โ€‹โ€‹in pairs in a vector. I use an iterator to point to the location in the vector that I want to access. Here are the code fragments containing the vector:

In the header file:

vector<pair<double, double> > points;
vector<pair<double, double> >::iterator headingTo;

In the constructor:

 points.push_back(make_pair(1700.00, 3300.00));//Plus 20 or so other values
 headingTo = points.begin();

In the method:

double x = headingTo->first - positionX;
double y = headingTo->second - positionY;

However, when I run this code, y is not generated. It is not shown in Visual Studio at all when I use a breakpoint to see variables. However, if I swap strings around, y is available, but x is not. Any ideas?

Edit: I found the following work:

double headingToX = headingTo->first; 
headingToX -= positionX;
double headingToY = headingTo->second;
headingToY-= positionY;
+3
source share
2 answers

, - , , .

, , , . Express V++ 2010 , Microsoft ( ):

, , ? .pdb "mov", , , ( ). โ€‹โ€‹, , .

, ( ), , , . .

, , , y .

+3

. , , ( ). , ( , ), .

, .

+2

All Articles