Mike wrote:
int *pos; //position x/y
pos = new int[x*y];
but how could I check or set f. ex:
pos.x=a;
or why is this wrong:
pos->y = y;
pos.x = a; doesn't work because pos is a pointer to int. Pointers don't
have members.
pos->y = y; doesn't work because it's equivalent to (*pos).y = y; and
*pos is an int. ints also don't have members.
More to the point, what you're trying to achieve is unclear. If what you
want is a position type (judging by the comment), then you need to
actually create a type, e.g. (very simple example -- not intended to be
a good design):
struct Pos
{
int x, y;
};
//...
Pos pos;
pos.x = 3;
pos.y = 4;
If what you want is a 2D grid of ints, then use e.g.
std::vector<std::vector<int> >:
int height = 23, width = 9;
std::vector<std::vector<int> > v(height);
for(int i=0; i<height; ++i) v[i].resize(width);
v[3][4] = 5;