Class and Scope Declarations

In C++, a class declaration introduces the class name into the scope where it is declared and hides any object, function, or other declaration of that name in an enclosing scope. In ISO/ANSI C, an inner scope declaration of a struct name does not hide an object or function of that name in an outer scope. For example:

double db;
void main ()
{
     struct db               // hides double object db in C++
     { char* str; };
     int x = sizeof(db);     // size of struct in C++
                             // size of double in ISO/ANSI C
}


Scope of Class Names


Scope in C++