For Each Loop in C++
HTML-код
- Опубликовано: 7 фев 2024
- C++ For Each Loops, also known as ranged based for loop in C++. In this video, you will learn about for each loops in C++ and how to iterate through a vector printing the values in the vector. You will also learn the differences between a for loop and a for each loop. Two differences you must understand is that with a for each loop: we cannot iterate backwards and we cannot directly modify the values at each index of a vector. Instead, you will learn how to do so using a normal for loop.
C++ Playlist:
• C++ Programming Tutorial
Install C++ with VS Code:
• How to set up C++ in V...
Subscribe for more coding tutorials 😄!
I've actually learnt c++ long back but then focused on java . Your channel is helping me understand c++ properly thank you!!!
You are an excellent teacher.
Never heard of const reference before till this point, really interesting, will definetely use it, thank you for the video!! Keep up the good work Kenny!!
Thank you very much for your great lessons!
There is only one thing I've noticed and I'd like to say about (if you don't mind).
We actually can change values in vector using a ranged base loop if we make reference. For example:
for (int& grade : grades)
{
++grade;
}
This loop should add 1 to each element in the original vector grades.
At least in my code it works :)
Ah yes you are correct! This slipped my mind since I hadn’t covered pointers and references at this point hahaha. But generally you wouldn’t be able to do this in other programming languages like java and Python!
@@KennyYipCoding Ok. Thank you very much for explanations.
Now I understand even better what I've read in one book about C++ : "in C++ you can basically do everything!" :D
Hello, if you have time can you please help me with a vscode - cpp problem. I did everything you did in the video related to this subject, but I still get an error
what is the error youre getting? Also have you checked the comment section of the installation video? Many users have pointed out some small issues they had and how to fix them. Perhaps one of them is an issue you're having?
@@KennyYipCoding sorry for not getting back to you. The issue is fixed and its now working properly. Thank you either way!
Kenny, I really like your course, your presentation style and your teaching examples! Unfortunately,the algorithm presents them totally disjointed, because you seem not to have numbered then properly in the title. So,I am left chasing hundreds of videos up and down trying to find the correct sequence. It is a real shame! Any chance you could correct that oversight?
Hey! You can find the videos in order if you go to the playlist tab on my channel
ruclips.net/p/PLnKe36F30Y4ZDNIOZ51sX25pWKQ1pkpTE&si=cTpRFbdbj5no-CyL
@@KennyYipCoding thank you, I finally did! 😅