instantiated from here error

I'm getting this "instantiated from here" error and I'm clueless on why I'm getting it.

First of all, I define a class cPoint, with members floats: x, y, z, and then a couple of accessor functions as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cPoint::cPoint(float newX, float newY, float newZ){
    x = newX;
    y = newY;
    z = newZ;
}
float cPoint::getX(){
    return x;
}
float cPoint::getY(){
    return y;
}
float cPoint::getZ(){
    return z;
}


then I declare a distance function in my main.cpp as follows:
1
2
3
4
5
6
7
float distance(cPoint pnt1, cPoint pnt2){
    float dX = pnt1.getX() - pnt2.getX();
    float dY = pnt1.getY() - pnt2.getY();
    float dZ = pnt1.getZ() - pnt2.getZ();
    float dist = sqrt(dX*dX + dY*dY + dZ*dZ);
    return dist;
}


Finally, I utilize my distance function in my main function as follows:
1
2
3
    cPoint point1(1.0f,1.0f,1.0f);
    cPoint point2(2.0f,2.0f,2.0f);
    float dst = distance(point1, point2);


Upon Compiling, my compiler (CodeBlocks 8.02) spits out this error (where line 90 is float dst = distance(point1, point2);
main.cpp |90| instantiated from here|
stl_iterator_base_types.h|129|error: no type named `iterator_category' in `class cPoint'|
stl_iterator_base_types.h|130|error: no type named `value_type' in `class cPoint'|
stl_iterator_base_types.h|131|error: no type named `difference_type' in `class cPoint'|
stl_iterator_base_types.h|132|error: no type named `pointer' in `class cPoint'|
stl_iterator_base_types.h|133|error: no type named `reference' in `class cPoint'|

I'm not even sure why it is trying to use stl_iterator_base_types.h
I've done some reasarch into this error and it seems to appear in template class definitions. So I don't know why it is popping up here.

So, what can I do to modify my code so this will compile?
I only posted what I thought was significant parts of my code. If need be, I can post more of my code.

I would appreciate any help you could give me. Thanks
std::distance is provided in <iterator> I believe.

Try renaming your distance function to something else.
Genius! I knew it had be something simple like that.
I had no idea distance was provided in iterator, but now I know.

Thanks for the tip
Topic archived. No new replies allowed.