Just delare it outside any function in the CPP file, of course, before the functions.
If the same global is to be used in another Source File in the project, it should be declared again with the keyword < extern >.
Just try a very simple Message Box-based Application, with already initialized values, and then go further. I have succeeded it from the first attempt.
In our days, of big applications, the use of global variables is more and more limited, however.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hey
could anyone explain how to declare global variables in c++??
Just delare it outside any function in the CPP file, of course, before the functions.
If the same global is to be used in another Source File in the project, it should be declared again with the keyword < extern >.
Just try a very simple Message Box-based Application, with already initialized values, and then go further. I have succeeded it from the first attempt.
In our days, of big applications, the use of global variables is more and more limited, however.