Unable to get the class stored into a vector of a class inside class ...

I have:

1
2
3
4
5
struct Point {}
class_A
 my_vector<Point>;
class B
 class_A * my_classA


I want to 'extract' the Point information of the vector of classA inside classB
Code Inside classB :
Point = my_classA->my_vector[8]; // 8 in example

I have two kind of errors :
1.- no matching function for call to ... candidates are ....
2.- conversion from ... to non-scalar type ...requested

Any help ? Thanks

What is that code supposed to do? The first three lines are all one statement:
struct Point {} class_A my_vector<Point>;
^ up to here this creates a variable class_A of type Point, but what
is the next bit for?

As for the second half, I'm not sure, since I don't know what class_A or my_classA are.

Are you sure that is C++ code? Perhaps I have misread something. :)

Last edited on
Provided that the code you posted is not the code you compile, this should be fine. Please post a compilable piece of code which reproduces the errors. It's hard to say now..
1.- no matching function for call to ... candidates are ....
2.- conversion from ... to non-scalar type ...requested
Those error messages are awful, you ought to change your compiler.

By the way it is type name;
The piece of code exposed was a brief, here is more information.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);
};
}


At add_wpoints this is the code :


1
2
3
4
5
void W_geo::WM_points3D::add_wpoints(W_points * w_points) {
   for (int i=0;i<10;i++)
 {   Point3D my_point =  w_points->vec_points3D[i];
    my_point.x-=w_points+100;
}


I cant to write the line :
Point3D my_point = w_points->vec_points3D[i];

I have the errors :
If I write :
W_geo::Point3D my_point = w_points->vec_points3D[n1];
conversion from 'std::vector<W_geo::Point3D>' to non-scalar type 'W_geo::Point3D' requested

And if I write another combinations I have
no matching function for call to ... candidates are ....


So, what is the solution ?
Thanks






Last edited on
Line 10 says that vec_points3D is a pointer to a vector. Now, since w_points->vec_points3D is a pointer, [i] just does some pointer arithmetics. You just need to take that * in line 10 off.
Also, line 4 (second snippet). double = pointer + 100 ? What is that supposed to do..?
MMM . I see, all the problem are pointers
I'm going to review my work
Thanks
Topic archived. No new replies allowed.