Nov 7, 2013 at 10:00am UTC
Hi.
How can I access to 'x' member from sf::Vector2i in my typedef?
I try this, but doesn´t work:
1 2 3 4
typedef std::vector<sf::Vector2i> FramesCoords;
FramesCoords *actualframecoords;
cout<<actualframecoords[2].x<<endl
;
Last edited on Nov 7, 2013 at 2:20pm UTC
Nov 7, 2013 at 10:48am UTC
Your syntax as wrong. If you want to access member b of object a , the syntax is:
a.b
If a is a pointer to the object, the syntax is:
a->b
EDIT: Also, what's the comma doing in line 4? Do you understand what the comma operator does in C and C++?
Last edited on Nov 7, 2013 at 10:49am UTC
Nov 7, 2013 at 2:10pm UTC
Sorry, it was my mistake while i was writting the post.
Anyway, does not work, neither actualframecoords[lastFrame].x nor actualframecoords[lastFrame]->x
Nov 7, 2013 at 2:21pm UTC
Since you've chose to withhold from us the error message you're getting and the definition of sf::Vector2i
, there's really no way for us to be able to tell what might be wrong.
Nov 7, 2013 at 2:31pm UTC
The error message:
Error: Frame Coords don't have a member named ' x'
sf::Vector2i have two members, X and Y.
Nov 7, 2013 at 2:48pm UTC
C and C++ are case-sensitive languages. x
is not the same as X
.
Nov 7, 2013 at 3:46pm UTC
@OP: for some reason you've got a pointer to a vector. In order to use the vector interface, you must dereference the pointer.