Chapter 2. auto Flashcards

1
Q

Item 5: Prefer auto to explicit type declarations.

A

auto variables must be initialized, are generally immune to type mismatches that can lead to portability or efficiency problems, can ease the process of refactoring, and typically require less typing than variables with explicitly specified types.

auto-typed variables are subject to the pitfalls described in Items 2 and 6.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Item 6: Use the explicitly typed initializer idiom when auto deduces undesired types.

A

“Invisible” proxy types can cause auto to deduce the “wrong” type for an initializing expression.

The explicitly typed initializer idiom forces auto to deduce the type you want it to have.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly