c. It's up to you how you organise your code, all you need is that after the preprocessor has finished with includes and everything else it does, file 2 has that line in it.
The main difference between Global and local variables is that global variables can be accessed globally in the entire program, whereas local variables can be accessed only within the function or block in which they are defined.
Global variable is a variable that is available throughout the program. An extern variable is also available throughout the program but extern only declares the variable but it doesn't allocate any memory for this variable.
The variables that are declared outside the given function are known as global variables. These do not stay limited to a specific function- which means that one can use any given function to not only access but also modify the global variables.
what is the difference between global variable and file variable in C++?
Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With