EXPLORATION 16

image

Type Synonyms

Using types such as std::vector<std::string>::size_type or std::map<std::string, int>::iterator can be clumsy, prone to typographical errors, and just plain annoying to type and read. Fortunately, C++ lets you define short synonyms for clumsy types. You can also use type synonyms to provide meaningful names for generic types. (The standard library has quite a few synonyms of the latter variety.) These synonyms are often referred to as typedefs, because the keyword you use to declare them is typedef.

typedef Declarations

C++ inherits the basic syntax and semantics of typedef from C, so you might already be familiar ...

Get Exploring C++ 11, Second Edition 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.