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 😄!

Комментарии • 12

  • @Akashjoshi-hj5vv
    @Akashjoshi-hj5vv Месяц назад

    I've actually learnt c++ long back but then focused on java . Your channel is helping me understand c++ properly thank you!!!

  • @dastin7276
    @dastin7276 3 месяца назад +1

    You are an excellent teacher.

  • @albana.campos9404
    @albana.campos9404 5 месяцев назад

    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!!

  • @Mariusz211
    @Mariusz211 2 месяца назад

    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 :)

    • @KennyYipCoding
      @KennyYipCoding  2 месяца назад

      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!

    • @Mariusz211
      @Mariusz211 2 месяца назад

      @@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

  • @razvan1318
    @razvan1318 5 месяцев назад

    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

    • @KennyYipCoding
      @KennyYipCoding  5 месяцев назад

      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?

    • @razvan1318
      @razvan1318 4 месяца назад

      @@KennyYipCoding sorry for not getting back to you. The issue is fixed and its now working properly. Thank you either way!

  • @helmutzollner5496
    @helmutzollner5496 18 часов назад

    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?

    • @KennyYipCoding
      @KennyYipCoding  17 часов назад +1

      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

    • @helmutzollner5496
      @helmutzollner5496 12 часов назад

      @@KennyYipCoding thank you, I finally did! 😅