Utilizor
Contact Us

C++ Scope

Understanding variable scope.

C++ Scope

In C++, variables are strictly scoped. This means that where you declare a variable matters.

Local Scope

A variable created inside a function belongs to the local scope of that function, and can only be used inside that function.

Global Scope

A variable created outside of any function, belongs to the global scope, and can be accessed from any scope.