I want to define an object, in this object I need to define two vectors which I don't know the size in advance. Can I do this in this way?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class cluster_type() {
public:
vector<point_type> point;
vector<line_type> line;
/*
point_type and line_type are defined, their construct function are also
defined
*/
cluster_type() {}
/*
I actually don't know how to construct it, when I call it I want an
cluster object created, in which there are an empty point_type vector and
an empty line_type vector, please help me out
*/
};
the other thing is how can I use such a class in an vector: for example how to:
1 2 3 4 5 6 7 8 9 10
//How to create a vector of this object?
vector<cluster_type> C;
C.push_back(cluster_type());
//How to use each one's member?
C[0].point.push_back(point_type()); //or
(C[0].point).push_back(point_type());
cout<<C[0].point[0];
If you look at the code, you know what I want to do, do you think I am doing it in the right way? Thanks alot!