Take the 2-minute tour ×

I have a point3 struct with 3 floats x y z (coordinates in 3-D space).

I create a few instances of point3, and then create a list and push those instances onto the list. Then I apply a translation function to the entire list.

Question: After applying the translation, how can I print out the X coordinate of one of the points in the list to check if my translation function does what I want it to?

Here is my code:

int main()
    point3 p1 = point3(0.0f, 0.0f, 0.0f);
    point3 p2 = point3(1.0f, 1.0f, 1.0f);
    point3 p3 = point3(2.0f, 2.0f, 2.0f);

    list<point3> myList;

    list<point3> myList2 = translateFact(myList, 1, 1, 1);

    std::cout << myList2.front.x; //<--- This is the line I'm having trouble with

//Translates the face by dx, dy, dz coordinates
list<point3> translateFact(list<point3> lop, float dx, float dy, float dz)
    list<point3>::iterator iter;

    for (iter = lop.begin() ; iter != lop.end(); iter++){
        point3 p = *iter;
        iter->x - dx;
        iter->y - dy;
        iter->z - dz;
    return lop;

The error I receive when trying to print myList2.front.x is

IntelliSense: a pointer to a bound function may only be used to call the function

so I think my issue is related to pointers, but I am unsure how. I just picked up C++ recently so I don't know enough about pointers to diagnose/fix the error.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You need parentheses to indicate that you want to call the front method:

std::cout << myList2.front().x;
share|improve this answer
Oh thank god it's something simple. Thank you very much Mr. Reed. Another quick question, do you know why my translateFact function is causing the error "identifier not found" when I call it on myList? –  Murkantilism Apr 18 '12 at 1:26
That's because compiler compiles code top to bottom. When it compiles main function, it doesn't see translateFact function, yet. Either put translateFact definition before main function, or declare translateFact function before main function and leave definition where it is now. –  Mārtiņš Možeiko Apr 18 '12 at 1:36
Ahhh I see, that makes sense thank you! –  Murkantilism Apr 18 '12 at 1:38
You're welcome! But note that editing the post and removing the original question results in a page that is confusing to those who come later; SO answers are for posterity as well as the original poster. You might want to put back the original error message, etc. –  Mark Reed Apr 18 '12 at 2:00
add comment

Your Answer


