Local Types

A new type name can be introduced via the typedef specifier or via the declaration of a class. A type name defined within the body of a class or function is referred to as a local type. Type names obey the same rules of scope as do other names (see also local classes).

The following restrictions apply to the redefinition of names within the body of a class declaration:


typedef int Integer;

enum {arraySize=10};
struct test
 char arrayCharacter[arraySize]; // An array of character of size arraySize.
 enum {arraySize=20};            // Syntax Error !! arraySize already
                                 // used in declaring array.
 int IntegerSize()               // A method that uses type 'Integer'.
 {return sizeof(Integer);}   

 char Integer;                   // Syntax Error !! Can't define Integer to be a variable
                                 // because type 'Integer' already used by method IntegerSize.
 typedef long Integer;           // Syntax Error !! Can't redefine type 'Integer' - again
                                 // because method IntegerSize has already made use of it.