Mega Code Archive

 
Categories / C++ / Function
 

The Scope Resolution Operator

#include <iostream> using namespace std; int count1 = 100;                             int main() {                                                int count1 = 10;    int count3 = 50;    cout << "Value of outer count1 = " << count1 << endl;    cout << "Value of global count1 = " << ::count1 << endl;    {                                                 int count1 = 20;                               int count2 = 30;       cout << "Value of inner count1 = " << count1 << endl;       cout << "Value of global count1 = " << ::count1 << endl;       count1 += 3;       count3 += count2;    }    cout << "Value of outer count1 = " << count1 << endl         << "Value of outer count3 = " << count3 << endl;    return 0; }