cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Vectors in class
Vectors in class
Apr 19, 2014 at 10:35pm UTC
Kanwarpreet
(14)
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
Apr 20, 2014 at 1:01am UTC
RadWayne
(97)
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
Apr 20, 2014 at 1:06am UTC
Topic archived. No new replies allowed.