Mega Code Archive

 
Categories / C++ Tutorial / Language Basics
 

Function in a namespace reference variables in the same namespace

#include <iostream> using namespace std; int integer1 = 98; namespace Example {    const double PI = 3.14159;    void printValues();    namespace Inner    {       enum Years { FISCAL1 = 1990, FISCAL2, a };    } } namespace {    double doubleInUnnamed = 88.22; } int main() {    Example::printValues();    return 0; } void Example::printValues() {    cout << integer1 << "\n(global) integer1 = " << ::integer1       << "\nIinteger1 = " << Inner::a << endl; } 98 (global) integer1 = 98 Iinteger1 = 1992