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;
myList.push_front(p1);
myList.push_front(p2);
myList.push_front(p3);
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.
You need parentheses to indicate that you want to call the
frontmethod: