What is a scope resolution operator in C ?


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.

int x = 10;
int main() 
  int x = 20;
  printf("%d\n", ::x);
  return 0;

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    C Programming Interview Questions

    What are static variables in C ?

    C defines another class of variables called static variables. Static variables are of two types:Static variables tha..

    C Programming Interview Questions

    What is register variable in C language ?

    C language allows the use of the prefix register in primitive variable declarations. Such variables are called register..

    C Programming Interview Questions

    What is a structure in C Language.How to initialise a structure in C?

    A structure is a composite data type declaration that defines a physically grouped list of variables to be placed under..