Hi guys, I defined a vector of a struct "element" as type(that I created) and I had problems on use it.
This is my struct:
1 2 3 4
|
typedef struct element{
int x, y, g;
float f;
};
|
And the declaration of the vector:
vector<element> closed_set();
When a try to use in expressions like below, I have the follow error message: "error: pointer to a function used in arithmetic".
if(closed_set[i]->x == 10){...}
Could anyone help me to figure this out?
Last edited on
Does if(closed_set[i].x == 10){...}
work for you?
Sorry -- I should have seen it earlier:
vector<element> closed_set; // remove parens.
Also:
typedef struct element{...};
is redundant.
struct element {...};
is what you want for C++. struct is a type specifier in C++, just like class.
it's working now!
Thanks for the help.