As the title says please.

The issue I'm having is I've got a class which holds the vector. When I create a new instance of the class I assume a new vector is also created which results in the vector losing all its contents?

Recommended Answers

All 3 Replies

No problem, I worked it out.

It seems that whenever I post on here I somehow manage to do it a couple minutes later having struggled previously for hours!!

I believe you meant how to create a static vector. If you want to make a class that will have a vector, which values won't change when creating instances of the class (namely objects) then use the static keyword.

class A{
static  vector v
}

Btw, try googling more next time with different kwywords. ;-) :)

Cheers :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.