# 复合类型

## 引用

Declaration 就是一个 Base Type 后接上一些 declarators

## 指针

Unlike a reference, a pointer is an object in its own right.

A pointer holds the address of another object.

& is the address-of operator.

### Pointer values

The value stored in a pointer can be in one of four states:

1. It can point to an object
2. It can point to the location just immediately past the end of an object
3. It can be a null pointer, indicating that it is not bound to any object
4. It can be invalid; values other than the preceding three are invalid

### Null Pointers

A null pointer doesn’t point to any object.

# const 关键字

The compiler will usually replace uses of the variable with its corresponding value during compilation.

To substitute the value for the variable, the compiler has to see the variable’s initializer. When we split a program into multiple files, every file that uses the const must have access to its initializer. In order to see the initializer, the variable must be defined in every file that wants to use the variable’s value (§ 2.2.2, p. 45).

To support this usage, yet avoid multiple definitions of the same variable, const variables are defined as local to the file. When we define a const with the same name in multiple files, it is as if we had written definitions for separate variables in each file.

To define a single instance of a const variable, we use the keyword extern on both its definition and declaration(s):

## Reference to const

We can bind a reference to an object of a const type.

A reference to const cannot be used to change the object to which the reference is bound:

## Initialization and References to const

We can initialize a reference to const from any expression that can be converted to the type of the reference. In particular, we can bind a reference to const to a nonconst object.

## Pointers and const

References and pointers to const，它们认为自己引用或指向的对象是常量的。

# Dealing with Types

## Type Aliases

An alias declaration starts with the keyword using followed by the alias name and an =.

## The auto Type Specifier

we can let the compiler figure out the type for us by using the auto type specifier.

auto 推断出来的类型，会丢弃 top-level const，使用引用对象原本的类型

Because a declaration can involve only a single base type, the initializers for all the variables in the declaration must have types that are consistent with each other:

## The decltype Type Specifier

When the expression to which we apply decltype is a variable, decltype returns the type of that variable, including top-level const and references: