Cant access to a struct member on a vector of a class.

I hope do you understand my question.

I have open another question with this code but this one is slightly different :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
namespace W_geo {

struct Point3D {
  double x,y,z;short  tipo; short capa;
};

class W_points {
public :
    W_points();
    vector <Point3D> * vec_points3D;
};

class WM_points3D {
public :
    WM_points3D();
    void add_wpoints(W_points * w_points);
};
}



Ok, at add_wpoints I have
w_points->vec_point3D[i].x;
And compiler tells me that vec_point3D has not x member ....?
Any idea ? Thanks
vec_points3D is a pointer, so you need to dereference it first.
Why did you decide to make it a pointer anyway?
Because I create it with a knowed number of items as new ....
And I pass it to another functions using pointer.
Have not to do it so ?
Thanks
Eh? You need a two-dimensional structure? Then why don't you use a vector of a vector?
In any case, you'll have to provide a second index.

And I pass it to another functions using pointer.

That's no reason to use a pointer in the class. You can get an object's address at any time using the address operator (&).
Ok, thanks.
I'm going to review the pointers concept-
Topic archived. No new replies allowed.