Vectors in class

Hello

I am defining a class called node that contain number of variables but I want to declare a vector in it as well such that for every node there is a vector that stores some data but i don't know how to store data in this vector and then process it.

Any suggestions?

Thanks

See http://www.cplusplus.com/reference/vector/vector/ for general help with vectors.

I'm not really sure what specifically you are asking about.

Here's an example of a vector ins a class

1
2
3
4
5
6
class Node
{
    std::vector<int> myvector;
    public:
    Node() : myvector(100,0) {}
};


The above creates a vector of 100 0's when Node is initiialized
Last edited on
Topic archived. No new replies allowed.