Not a member of?

Hi,

This is probably a VERY simple problem. Basically I've set a 2D structure:

1
2
3
4
5
struct IntegerCoordinate
{
	unsigned X;
	unsigned Y;
};


and then made a function class which has inherited from another class (which is all fine), with this bit of code:

1
2
3
4
5
6
7
// storage for the new vector class 
  vector<IntegerCoordinate> v;
  public:
	// constructor
	// functions
	void set_x(unsigned x) { v.X = x; }
	void set_y(unsigned y) { v.Y = y; }


But I'm producing the error

1
2
3
4
5
'X' : is not a member of 'std::vector<_Ty>'
1>          with
1>          [
1>              _Ty=IntegerCoordinate
1>          ]


Help would be appreciated, thank you!
In this code, v is a std::vector, which has no member x. But the vector is filled with objects which do have a member x.

Not entirely sure what your code is supposed to be but this set x of elements in the vector...

1
2
3
4
5
6
7
// storage for the new vector class 
  vector<IntegerCoordinate> v;
  public:
	// constructor
	// functions
	void set_x(unsigned x) { v[i++].X = x; }
	void set_y(unsigned y) { v[i++].Y = y; 
Last edited on
v is a std::vector, not an IntegerCoordinate. What you want to do is set the x and y of a coordinate that is stored in the vector:
 
v[ 0 ].X = x;
Basically, what I'm trying to do is create a vector v filled with IntegerCoordinates.

But I'd like to be able to change the values of the IntegerCoordinates, and change them. So I'm assuming I've done this completely wrong...?
Topic archived. No new replies allowed.