Share this post

Link to post

Share on other sites

Original post by alex_and_his_towelGuess I'll have to stick the vector in the main() function and pass it to other functions. Only a few functions use it anyway.

Alex.

Well, passing the vector to other functions may turn out to be the best way, but you can still declare it globally. Just keep vector<string> testVector where it is, and just move the push_back functions into main.

Share this post

Link to post

Share on other sites

There's a proposal for the next revision of the C++ standard that's supposed to make code like that more palettable. Within the current version, you can also change things around to make it easier to look at.Ex: