liveBook · Manning

Auto

auto is a language feature that directs the compiler to deduce an object's type from its initializer.

How 3 Manning books explain it

Learn C++ by Example

Auto type deduction is the C++ language feature that lets the compiler infer a variable's type from its initializer.

How it is used
Uses type deduction to simplify variables, range-based loops, container code, generic addition, and selected function declarations.
How deep it goes
Explains deduction through expressions, containers, iterators, templates, and return types, while deferring fuller lambda and closure treatment.
Examples
Demonstrates arithmetic promotion, std::plus, vector iteration, Pascal's triangle, nested-vector returns, and generic lambdas.
What you can do after
Apply auto to simplify container programs, generic functions, range loops, and deduced function returns.

Read how Learn C++ by Example explains auto →

Modern C, Third Edition

auto is a C23 type-inference feature that allows an object's type to be inferred from its initializer.

How it is used
Supports type-generic declarations whose types must follow initializer expressions, especially inside macros and library-result handling.
How deep it goes
Explains initializer-based inference through SWAP and div examples, but does not enumerate the complete declaration constraint set.
Examples
Uses inferred arithmetic variables, a generic SWAP macro, and a div result exposing quotient and remainder members.
What you can do after
Apply it to maintain type consistency in generic declarations and to capture structure-valued results without spelling their types.

Read how Modern C, Third Edition explains auto →

100 C++ Mistakes and How to Avoid Them

auto is a C++ declaration specifier that asks the compiler to deduce a variable's type from its initializer.

How it is used
Uses type inference to simplify variable, iterator, and loop declarations in modern C++.
How deep it goes
Explains initializer-based deduction and a signedness failure, but does not develop deduction rules beyond these practical cases.
Examples
Uses index loops, vector searches, iterator declarations, reverse iteration, and references returned from student names.
What you can do after
Evaluate/understand when deduction improves declarations and when an explicitly signed counter prevents unsigned wraparound.

Read how 100 C++ Mistakes and How to Avoid Them explains auto →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.