- [Bill] Beginning with the C++11 version of C++,…there's a new range-based for loop.…This gives C++ a simple way…of iterating over the elements of a container,…an operation that used to take a bit more code.…So here in Xcode, I've left open our for.cpp…from the previous lesson,…and here, I'm actually going to change this…and make this back into our integer array.…
And down here, we're going to iterate through this array…with a range-based for loop.…So, it goes like this for…int i…in array,…and we have that colon there,…which tells us that we're iterating through a container…and the container's the right of the colon…and what each element of the container is going to be put in…is the left of the colon,…and so, each element of the array…will be placed in this integer i…during the for loop,…and so, I can simply say printf…i…is…%d…for an integer,…like that.…
And when I build and run,…you notice we get i as one, two, three, four, and five.…Now, our range-based for loop…is a compiled time feature,…and so, even though this is a simple c array…
Author
Released
12/19/2018- Setting up Xcode and Visual Studio
- Statements and expressions
- Variables
- Primitive arrays and strings
- Conditionals
- Loops
- Data types
- Operators
- Functions
- Classes and objects
- Templates
- Standard Library and Standard Template Library
Skill Level Intermediate
Duration
Views
Related Courses
-
Learning C++ Pointers
with Peggy Fisher53m 55s Intermediate -
Learning C++
with Erin Colvin2h 26m Beginner
-
Introduction
-
About this course1m 2s
-
Using the exercise files1m 10s
-
What is C++?4m 7s
-
-
1. Installation
-
2. Basic Syntax
-
Anatomy of a C++ program8m 43s
-
Statements and expressions3m 23s
-
Identifiers2m 23s
-
Defining variables3m 6s
-
Pointers4m 29s
-
References3m 27s
-
Primitive arrays3m 11s
-
Primitive strings3m 58s
-
Conditionals5m 6s
-
The branching conditional2m 55s
-
Iterating with for4m 42s
-
Range-based for loop3m 41s
-
Using stdout6m 58s
-
3. Data Types
-
Overview of data types3m 9s
-
Integer types2m 26s
-
Integer sizes6m 7s
-
Fixed-size integers4m 7s
-
Floating point types5m 41s
-
Characters and strings3m 53s
-
Character-escape sequences3m 40s
-
Qualifiers6m 1s
-
References5m 43s
-
Structured data2m 23s
-
Bit fields2m 45s
-
Enumerations3m 55s
-
Unions2m 47s
-
Defining types with typedef2m 22s
-
The void type2m 23s
-
The auto type3m 24s
-
-
4. Operators
-
Common operators2m 54s
-
Logical operators2m 17s
-
Bitwise operators3m 29s
-
Ternary conditional operator1m 47s
-
Dynamic memory operators7m 14s
-
Type cast3m 14s
-
Using sizeof4m
-
Using typeid2m 44s
-
Operator precedence2m 13s
-
-
5. Functions
-
Overview of C++ functions3m 32s
-
Creating a function3m 20s
-
Passing values to a function6m 13s
-
Using function pointers6m 22s
-
-
6. Classes and Objects
-
Defining a class3m 32s
-
Data members3m 56s
-
Function members6m 44s
-
Constructors and destructors6m 10s
-
Overloading operators6m 34s
-
7. Templates
-
Understanding templates2m 48s
-
Template functions4m 42s
-
Template classes3m 42s
-
-
8. Standard Library
-
File I/O4m 45s
-
Binary files4m 22s
-
File management4m 11s
-
Unformatted character I/O5m 57s
-
Formatted character I/O3m 34s
-
String functions5m 2s
-
Handling system errors2m 33s
-
9. Standard Template Library (STL)
-
Overview of the STL2m 25s
-
Vectors3m 56s
-
Strings3m 33s
-
I/O streams8m 3s
-
Handling exceptions4m 22s
-
-
Conclusion
-
Thank you1m 30s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Range-based for loop