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......

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


o Example program.

See Also:

o C++ operators..

C References

o Global Variables.

o C Expressions and Operators.

Top Master Index Keywords Functions

Martin Leslie