Range Based For Loop | C++ Tutorial

  Рет қаралды 6,883

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 17
@davidkim617
@davidkim617 2 жыл бұрын
I'm a beginner C++ programmer, and to me your explanation is just perfect. Thanks!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome David, I'm glad to hear it was helpful! 😀
@lucasgroves137
@lucasgroves137 Жыл бұрын
Nice one yet again, Kevin. Appreciate the clarity and of course as always, the utter lack of fluff. 👍
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I'm glad you enjoyed it Lucas! :-D
@franzageek
@franzageek Жыл бұрын
I cannot get the range-based for loop to work with my on-heap array. How come?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
This stackoverflow answer coves this issue and has a workaround too: stackoverflow.com/a/15919834. :-)
@karimbousmaha4038
@karimbousmaha4038 5 ай бұрын
Plz share a Playlist about making some games with graphics in c++
@ValliNayagamChokkalingam
@ValliNayagamChokkalingam Жыл бұрын
Thanks once again for everything! char my_array [] - here my_array is essentially a pointer to the first character - so when we declare a string using a pointer directly - char* my _array = "Portfolio"; - why am I getting this error - Error (active) E0144 a value of type "const char *" cannot be used to initialize an entity of type "char *' - I am also not able to modify individual characters in a string after declaring the string because of the read only permission. Thanks!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
This video may answer some of your questions regarding char * vs char [] and storing strings: kzbin.info/www/bejne/h6GWiJSqgbGSfsU. It looks like you may run into issues trying to use strings stored this way with range-based for loops, the recommendation seems to be to use it to create a proper string in C++: stackoverflow.com/questions/18020517/using-range-based-for-loops-with-char-pointer-string.
@rajendranm2204
@rajendranm2204 Жыл бұрын
hi, is it possible to print a int* which is pointing to 3 elements using Range Based For Loop?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I think you could do it using a technique like in this answer: stackoverflow.com/a/64199190. :-)
@rajendranm2204
@rajendranm2204 Жыл бұрын
Thanks
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@aegr4923
@aegr4923 2 жыл бұрын
how do if i want to print the indexes of the array?, example : cars indexes of 1, ship indexes of 2 etc
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Great question! :-) You could use a variable like this answer here on Stackoverflow: stackoverflow.com/a/15149476. Or instead of a range-based for loop you could use a regular for loop instead with a counter variable i that keeps track of the index in the array: kzbin.info/www/bejne/bnTHfICnjJl_eZY. If you want the array index, then a range based for loop probably isn't the best approach, I would suggest using a regular for loop instead.
@aadhuu
@aadhuu 2 жыл бұрын
Nice explanation!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you, I’m glad you enjoyed it! :-)
Default Arguments | C++ Tutorial
8:22
Portfolio Courses
Рет қаралды 3,4 М.
Member Initializer Lists | C++ Tutorial
23:10
Portfolio Courses
Рет қаралды 10 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Loops in C++ (for loops, while loops)
12:20
The Cherno
Рет қаралды 424 М.
Class Templates | C++ Tutorial
12:48
Portfolio Courses
Рет қаралды 60 М.
Range based for loop in C++ | C++ Tutorials for Beginners #lec34
18:27
Jenny's Lectures CS IT
Рет қаралды 19 М.
you will never ask about pointers again after watching this video
8:03
C++ Tutorial -   Loops In C++ [For Loop, While Loop, Do While Loop]
16:20
C++ arrays (#19) 🚗
21:09
Bro Code
Рет қаралды 26 М.
Multiple Inheritance Deep Dive | C++ Tutorial
14:53
Portfolio Courses
Рет қаралды 11 М.
Arrays and Looping - C++ Tutorial 19
11:44
Caleb Curry
Рет қаралды 12 М.
How to REALLY learn C++
8:13
The Cherno
Рет қаралды 818 М.