In C, we cannot access a global variable if we have a local variable with same name, but it is possible in C++ using scope resolution operator (::).
#include<iostream.h> #include<conio.h> int a=10; void main() { clrscr(); int a=15; cout<<"Local a:"<<a<<endl<<"Global a:"<<::a; getch(); }
Local a:15 Global a:10
Copy Program