how would i make a pointer to a vector?
thx
how would i make a pointer to a vector?
thx
Post an example of a vector container.
Kuphryn
There aren't very many good reasons to do that. Why do you want to?
The answer is the same as for any other type.
Maybe...
Code:vector<int> int_vect; vector<int> * ptr_int_vect; ptr_int_vect = &int_vect;
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
i wanted to do it so that a class can access a vector located in the main program, without having to pass it as a parameter for every function call.
That might be one of the few reasons to have a pointer, although if the vector will always be there (and can never be null), then a reference would probably be better.
I think it would be tons better to use a global static class or namespace. With a pointer, you'd have to handle allocation, scope, errors and such.