The STL's favorite type is not int, float, or double, but something called size_t. Troy explains what it is and how to use it and adds an explanation of using auto as a return type.
- [Instructor] Size_t is a basic unsigned integer.…It's size depends on the system.…It can store the maximum size…of a theoretically possible object of any type,…including a ray.…Using size_t can improve your code's…portability and efficiency.…Most index containers in the STL use size type,…which is another name for size_t.…Since C++14, you can use auto as a return type,…but all returns should have the same type.…
We have a code sample to illustrate the points.…So, let's switch over to Visual Studio Code.…And let's start off that we have…this function called, sumDown,…and it is a recursive add function.…You give it a number like 10,…and it'll keep going from 10 all the way down to zero,…and add all the numbers up along the way.…Now, notice that we have a type auto here…and we have a return type of zero for an integer.…And also, this is going to be an integer…of what's getting added here.…
And that's using auto as a return type.…Now here, we're using size_t in a various different ways.…We're going to create a constant N,…
- Major new C++ features
- Turning on modern C++
- Letting the compiler help
- Using the new features correctly
- Using auto type deduction
- Using lambdas
- Range-based for loops
- How C++ and the Standard Template Library name things
- Making the best of the filesystem library
- Managing objects
Skill Level Beginner
1. What Is Modern C++?
2. Tools That Improve Your Code
3. Using the New Features Correctly
4. Don't Reinvent the Wheel
5. Managing Objects
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.