global variables

This is going to sound like a stupid question, but here goes:

Are global variables expressed in the main? It seems that only local variables enclosed in brackets are, and global variables follow the namespace std. Why is that? I guess I would think that global variables would be established in the main function, as this is what function is initially processed before all others. But perhaps the global variables are expressed in the namespace std because this declares which entities will be used.. I dunno I think I sort of get it but not completely.



Nope, variables declared within main are only valid within the scope of main.

Global variables are usually declared above main and are accessible by any function in your code. Generally, they should be avoided.
Global variables are in the global namespace from what I remember. Outside of the that, if you make a local variable with the same name as the global then the local variable is used. Though, I'm not entirely sure what you are asking.
Topic archived. No new replies allowed.