Posted On: Feb 22, 2018
The scope resolution operator (::) is useful in C programming when both global and local variables have the same name, a statement using that name will access the local variable (more precisely, it will access the variable of that name in the innermost block containing that statement).
The scope resolution operator represented as :: (a double colon) can be used to select the global variable explicitly.
Consider the example below.
#include<stdio.h> int x = 10; int main() { int x = 20; printf("%d\n",x); printf("%d\n", ::x); return 0; } OutPut: 20 10
Never Miss an Articles from us.
C defines another class of variables called static variables. Static variables are of two types:Static variables tha..
C language allows the use of the prefix register in primitive variable declarations. Such variables are called register..
A structure is a composite data type declaration that defines a physically grouped list of variables to be placed under..