Click here to Skip to main content
15,891,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want a vector that should be global, so that i can access it anywhere in my project.
thanks in Advanced.
Posted
Comments
Maciej Los 10-Apr-15 8:47am    
Why?
Richard MacCutchan 10-Apr-15 11:29am    
So make it a global variable. What is the problem?
Sergey Alexandrovich Kryukov 10-Apr-15 11:59am    
Using global variables is a sign of bad code design. Why doing it?
—SA

1 solution

It really sounds like poor design. It will make you trouble some day, so you harm yourself.

If you want to shot you in the knee:

in one (1) header or the class header
C++
extern MyVector theGlobal;


in one (1) cpp file or best the class implementation
C++
MyVector theGlobal;


Please read about MVC architecture to enhance your knowledge. (As thank for the answer)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Apr-15 15:29pm    
Agree, my 5. However, it's possible that the inquirer also needs to understand the use of extern declaration and the nature of C/C++ linkage, which causes a lot of difficulties in many.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900