Listing 5 C and C++ declarations and definitions

int a;     /* OK in C      - tentative definition.
            OK in C++    - definition. */
int a;     /* OK in C      - redeclaration.
            Error in C++ - redefinition. */
int a = 0; /* OK in C      - definition.
            Error in C++ - redefinition. */


extern int b;     /* OK in C    - tentative definition.
                  OK in C++ - declaration. */
extern int b;     /* OK in both - redeclaration. */
extern int b = 0; /* OK in both - definition. */

static int c;     /* OK in C       - tentative definition.
                  OK in C++    - definition. */
static int c;     /* OK in C       - redeclaration.
                  Error in C++ - redefinition. */
static int c - 0; /* OK in C       - definition.
                  Error in C++ - redefinition. */


int const d; /* OK in C    - tentative definition.
             Error in C++ - definition of internally
             linked const object must be
             initialized. */

void e(int);   /* OK in both - declaration. */
void e(long f) /* Error in C - definition/declaration
                  mismatch.
                  OK in C++ - overloaded definition. */
   {
   int g; /* OK in both    - definition. */
   int g; /* Error in both - redefinition */
   }
/* End of File */