# Scope in C++.

The :: operator is used within C++ to identify global variables that conflict with local variable names. Obviously it would be good programming practice to use suitable names in the first place......

            #include <iostream.h>

            int Counter = 1;

            main()
            {
                int Counter = 1;

                for (int i=0; i< 10; i++)
                {
                    cout << Counter << " " << ::Counter << endl;
                    Counter++;
                }

                return 0;
            }

## Examples:

Example program.

## See Also:

C++ operators..

## C References

Global Variables.

C Expressions and Operators.

Top | Master Index | Keywords | Functions