Names with No Linkage

The only names that have no linkage are:

Because typedef names have no linkage, their definitions can differ between translation units. Because the compilations take place discretely, there is no way for the compiler to detect these differences. As a result, errors of this kind are not detected until link time. Consider the following case:

// Translation unit 1
typedef int INT

INT myInt;
...

// Translation unit 2
typedef short INT

extern INT myInt;
...

The preceding code generates an “unresolved external” error at link time.

C++ functions can be defined only in file or class scope. The following example illustrates how to define functions and shows an erroneous function definition:

#include <iostream.h>

void ShowChar( char ch );    // Declare function ShowChar.

void ShowChar( char ch )     // Define function ShowChar.
{                            // Function has file scope.
   cout << ch;
}

struct Char                  // Define class Char.
{
    char Show();             // Declare Show function.
    char Get();              // Declare Get function.
    char ch;
};

char Char::Show()            // Define Show function
{                            //  with class scope.
    cout << ch;
    return ch;
}

void GoodFuncDef( char ch )  // Define GoodFuncDef
{                            //  with file scope.
    int BadFuncDef( int i )  // Erroneous attempt to
    {                        //  nest functions.
        return i * 7;
    }
    for( int i = 0; i < BadFuncDef( 2 ); ++i )
        cout << ch;
    cout << "\n";
}