Use of static variables and functions in global scope
Is there a use for flagging a variable as static , when it lies in the global scope of a .cpp file, not in a function? Can you use the static keyword for functions as well? If yes, what is their use? In this case, keyword static means the function or variable can only be used by code in the same cpp file. The associated symbol will not be exported and won't be usable by other modules. This is good practice to avoid name clashing in big software when you know your global functions or variables are not needed in other modules. Nawaz Yes, if you want to declare file-scope variable, then static