Scope of code (C++)

Here’s the example they showed:
They say that i is a global variable, but I don’t get it, because it is inside of the print function. How is that not a local variable? Thanks.

Where i is declared, it is not inside of any method/function.
Since it is declared int i = 10; outside of any method/function, it can be accessed inside of print() and main(), which it is.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.