Chapter 1.5

ES.10: Declare one name (only) per declaration

Let me introduce you

A declaration introduces a name into the program. It can also reintroduce a name: multiple declarations are entirely permissible, for without them we would be unable to have forward declarations. A definition is a special kind of declaration, since it provides enough detail to be able to use the thing that has been named.

There are a surprising number of types of declaration. You can declare functions, like this:

int fn(int a);

This is a very common use of declarations. A name is being introduced, fn, which is of type “function taking an integer and returning an integer.” You can use this func-tion in your code without having to define it first. You can declare ...

Get Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.