A Program to access 'Global Variable' into a function which already contains variable with similar name as Global Variable:-


#include<iostream.h>
#include<conio.h>

int a=10;
void main()
{
clrscr();
int a=15;
cout<<"Local a:"<<a<<endl<<"Global a:"<<::a;
getch();
}

Output:


Local a:15
Global a:10

			

Previous Next