Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Scope defines the region of a program where a variable is visible and accessible. It prevents naming conflicts and manages memory efficiently.
Variables declared inside a function or block { }. Destroyed when the block exits.
Variables declared outside all functions. Accessible throughout the entire program's lifetime.
Use :: to access a global variable if a local variable with the same name exists in the current scope.
cout << ::x; // accesses global x