How to make variable accessible to all application?

Hi, I've got many classes and all of them needs one variable, how can I declare that variable so it can be accessible to all my classes?
By declaring it a header file that is included by all translation units, for example.
Create a header with global variables and then include it in all program headers? It throws an error C2086: 'int i' : redefinition every time I include global variable header
I hope you aren't planning to create a global variable called i of all things.
If it's not a constant, you'll have to declare it in the header as extern int not_i_please; and instantiate it in one of your translation units.
Topic archived. No new replies allowed.