From the course: C Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

The auto type

The auto type

- The auto type was introduced with C 11 and it has quickly become very common This is auto-type.CPP from chapter four of the exercise files. Here we see that we can declare an object based on the type of what it's being initialized with. This can be very convenient. So here on line 11, we have a standard string object from the STL, the standard template library, that comes with C . We've initialized it with a string, and we've named it S. Here on line 12, we have an autotype. We have X = S and the type of X is being automatically derived. Down here, we give the value of X and here we give the type of X using type ID. And what this does is it gives you the internal representation of what the type is and it can be a little bit confusing to look at. So I'm going to go ahead and run this and we'll take a look at what this looks like. You notice that it says type of X is and then this very long string and that's…

Contents