Note that there are some explanatory texts on larger screens.

plurals
  1. POPrinting a component of an element of a list in C++
    primarykey
    data
    text
    <p>I have a point3 struct with 3 floats x y z (coordinates in 3-D space). </p> <p>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.</p> <p><strong>Question:</strong> 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?</p> <p>Here is my code:</p> <pre><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&lt;point3&gt; myList; myList.push_front(p1); myList.push_front(p2); myList.push_front(p3); list&lt;point3&gt; myList2 = translateFact(myList, 1, 1, 1); std::cout &lt;&lt; myList2.front.x; //&lt;--- This is the line I'm having trouble with } //Translates the face by dx, dy, dz coordinates list&lt;point3&gt; translateFact(list&lt;point3&gt; lop, float dx, float dy, float dz) { list&lt;point3&gt;::iterator iter; for (iter = lop.begin() ; iter != lop.end(); iter++){ point3 p = *iter; iter-&gt;x - dx; iter-&gt;y - dy; iter-&gt;z - dz; } return lop; } </code></pre> <p>The error I receive when trying to print myList2.front.x is</p> <pre><code>IntelliSense: a pointer to a bound function may only be used to call the function </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload