Global variables are known throughout the entire program and may be used by any piece of code. : global variable « Language Basics « C++ Tutorial






#include <stdio.h>    
       
void func1(void), func2(void);   
     
int count;  
     
main(void)   
{   
  count = 100;   
  func1();   
  return 0; 
}   
     
void func1(void)   
{   
  int temp;   
     
  temp = count;   
  func2();   
  printf("count is %d", count); /* will print 100 */   
}   
     
void func2(void)   
{   
  int count;   
     
  for(count=1; count<10; count++)   
    putchar('.');   
}








1.5.global variable
1.5.1.Use a global variable
1.5.2.Global class variable
1.5.3.Global variables are known throughout the entire program and may be used by any piece of code.
1.5.4.Use :: to reference global variable