Declarations and Definitions

From Cppwiki

Jump to: navigation, search

Declarations and definitions serve to inform the compiler about elements of the code being parsed. Everything the compiler sees at file scope after being run through the preprocessor must be either a declaration or definition.

A declaration informs the compiler that something with the given name and characterists exists somewhere. A definition serves to create the named thing. Definitions will serve as declarations in all but a few cases.

Contents

Declarations

Simple declarations

Complex declarations

Declarations are always read from the inside out and right to left.

As an example: void (*(foo()))(); foo is declared as a function taking no arguments and returning a pointer to function that takes no arguments and returns nothing.

Definitions

Personal tools