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 - C Tutorial
From the course: C Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Overview of data types3m 21s
-
(Locked)
Integer types2m 43s
-
(Locked)
Floating point types6m 51s
-
(Locked)
The auto type4m 2s
-
(Locked)
Qualifiers4m 33s
-
(Locked)
Type aliases2m 5s
-
(Locked)
Primitive arrays5m 23s
-
(Locked)
C-strings4m 37s
-
(Locked)
Structures2m 50s
-
(Locked)
Challenge: Library card2m 9s
-
(Locked)
Solution: Library card1m 16s
-
-
-
-
-
-
-