Using the unary scope resolution operator :: - C++ Function

C++ examples for Function:Global Variable

Description

Using the unary scope resolution operator ::

Demo Code

#include <iostream>

int number = 7;  // global variable named number

int main(int argc, const char *argv[]) {
    double number = 10.0f;  // local variable named number

    std::cout << "Local double value of number = " << number
              << "\nGlobal int value of number = " << ::number << std::endl;
    return 0;//from   w  w w  .j  a v a 2s .  c o  m
}

Result


Related Tutorials