From the course: C++ Templates and the STL

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Type inference

Type inference

- [Instructor] In previous versions of C and C++, the auto keyword declared a variable in automatic storage and this was the default storage within a block anyway. So the keyword was rarely if ever used. So beginning with C++11, the auto keyword has been repurposed to provide type inference. Here I have a working copy of auto.cpp from Chapter 1 of the Exercise Files, and we have a number of variable definitions here beginning on Line 9. And you'll note that later on here I'm using typeid to get the internal names of the types. These names are implementation dependent. So if you're following along on a PC or another platform, these names will be different. When I build and run this, you see it displays the names, and it says things like PKc for a c-string and i for an integer and this long thing for the STL string class which is defined here, sclass. So these names will be different on different platforms just so that you're aware of that. You'll notice here on Line 13 I define a…

Contents