Use scope resolution operator to reference global variable. - C++ Function

C++ examples for Function:Global Variable

Description

Use scope resolution operator to reference global variable.

Demo Code

#include <iostream>
using namespace std;
double number = 42.5;         // a global variable named number
int main()//from ww w.j  av  a2 s.c o m
{
   double number = 26.4;       // a local variable named number
   cout << "The value of number is " << ::number << endl;
   return 0;
}

Result


Related Tutorials