Lambda expressions in modern C++ (in depth step by step tutorial)

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 มิ.ย. 2024
  • A lambda is an unnamed function that is used for short snippets of code that cannot be reused and are not worth naming.
    It makes the code cleaner, easier to read, and lambdas are also fast to execute.
    Lambdas are available in C++ version 11 and above.
    In this step by step in depth tutorial I'll teach you the most important things about lambda expressions, and also share some tips and tricks, and if you want to practice and see more examples of lambda expressions in modern C++, download free E-Book below.
    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.
    Download Visual Assist here: bit.ly/WT-CB
    I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
    Download Ultra Edit here: bit.ly/UE-CB
    It is a powerful, secure text editor designed specifically for programmers.
    👉To build this app I used C++Builder. You can download it here : bit.ly/CppBuilderFree
    ☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. Use the link to make a contribution: bit.ly/CodeBeauty_BuyMeACoffee
    However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇
    Find more C++ UI app tutorials here: bit.ly/cpp_ui_apps
    Contents:
    00:00 - What will you learn in this course?
    00:48 - Introduction to lambda expressions
    02:40 - Create and set up the project and console application
    03:44 - Basics of lambda expressions
    06:52 - What kind of problems are solved with lambdas?
    08:27 - Your first lambda
    10:03 - Why use lambdas?
    12:44 - Why are lambdas more powerful than ordinary functions? (Lambda captures)
    Follow me on other platforms:
    Instagram 📸 - / truecodebeauty
    Twitter 🐦- / truecodebeauty
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 219

  • @CodeBeauty
    @CodeBeauty  2 ปีที่แล้ว +29

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.

  • @coefficient1359
    @coefficient1359 2 ปีที่แล้ว +53

    I have asked for this topic like 7 months back and now got it. Thank you.

  • @abelashenafi6291
    @abelashenafi6291 11 หลายเดือนก่อน +5

    The beauty about your videos is, I always watch them to learn something I initially intended to but, I always end up learning some extra things. Thanks for that. You're awesome

  • @SAURABHJAIN1989
    @SAURABHJAIN1989 2 ปีที่แล้ว +5

    You are the best C++ Lecturer in TH-cam. You explain the topic with the example, including all other special features of C++. Like in this "lambda function" example, you also included 'Standard Template Library' vector and algorithm. That really connects with the real coding problems and uses of all other important features of C++.
    Thank you for teaching us, all these things :)
    Thanks a lot :)

  • @sunghunet
    @sunghunet 2 ปีที่แล้ว +3

    Today, I first learned lambda function of C++.
    I learned from the best. (Whitney's one of my favorite songs)!!

  • @voseAKUMA
    @voseAKUMA 2 ปีที่แล้ว +5

    Im learning c++ on udemy and I always come to your videos for second help. you always have a great way if explaining these concepts . Thank you for posting these videos. for real!

  • @awrmike
    @awrmike 2 ปีที่แล้ว +4

    Perfect timing! We are covering Delegates and Lambdas this week in my C# course.

  • @rupakdutta5577
    @rupakdutta5577 2 ปีที่แล้ว +5

    I was struggling with this topic since yesterday.. it's all clear to me now! Glad I came across your video..Thank you CodeBeauty, Keep making such videos!

  • @l.p.1967
    @l.p.1967 2 ปีที่แล้ว +17

    The best explanation, I need this video a lot, thank you CodeBeauty!!❤

  • @phoebewell3653
    @phoebewell3653 2 ปีที่แล้ว +10

    this video is so easy to understand, love it

  • @yairfink2368
    @yairfink2368 2 ปีที่แล้ว +2

    I love the way you teach the lesson, and in general your lessos are very helpful. Thank you very much.

  • @luisfernando3405
    @luisfernando3405 ปีที่แล้ว +1

    Hi, I'm from Brazil and a developer beginner but with much years at development using C++; Your channel is my favorite font to learning c++ and english; This is terrific. 🚀🚀

  • @hilgicamala2520
    @hilgicamala2520 2 ปีที่แล้ว +5

    You are so talented for teaching, the best teacher ever!

  • @j.r.waheed4610
    @j.r.waheed4610 2 ปีที่แล้ว +1

    Thank you. Best C++ lambda introduction I have seen thus far.

  • @gollygobih6527
    @gollygobih6527 2 ปีที่แล้ว +13

    Saldina you are the best as always ❤❤❤

  • @irfanjames6551
    @irfanjames6551 ปีที่แล้ว +14

    15:51 You can change the value (only in lambda function) by typing "mutable" between the circle and curly brackets.
    This way you don't have to change the variable in bigger scope by passing with reference.
    Disscussed in Cherno's video on lambdas th-cam.com/video/mWgmBBz0y8c/w-d-xo.html

    • @emaayan
      @emaayan ปีที่แล้ว

      yea i should have gone to cherno to learn about lambdas, cause she defined only function pointers in signatures.

  • @charltonmurphy7950
    @charltonmurphy7950 2 ปีที่แล้ว +2

    This video is awesome! Thank you I have a better understanding now. I am a struggling student and your videos help out greatly

  • @ZeroCool2211
    @ZeroCool2211 2 ปีที่แล้ว +6

    So useful and simple.. thank u Saldina 🌷

  • @adhaarsharma753
    @adhaarsharma753 2 ปีที่แล้ว +1

    Exactly what I was looking for. Best channel for C++

  • @DaleDix
    @DaleDix 2 ปีที่แล้ว +3

    First time it's ever really made sense to me. Thanks!

  • @marym9003
    @marym9003 2 ปีที่แล้ว +7

    These books are amazing, thanks for sharing free resources with us Saldina ❤️

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว

      Glad u like em 😃😃

  • @KostopravHD
    @KostopravHD 2 ปีที่แล้ว

    perfect tutor and perfect lesson. Thank you!

  • @shellongchow99
    @shellongchow99 2 ปีที่แล้ว +1

    Great description!Thank you!

  • @AdrianR.Calimag
    @AdrianR.Calimag 2 หลายเดือนก่อน +1

    Thanks for this lesson. I really need to learn this for our management project. Great teaching as always❤

    • @CodeBeauty
      @CodeBeauty  27 วันที่ผ่านมา

      You are so welcome 🥰

  • @meem71
    @meem71 2 ปีที่แล้ว +8

    I finally understood that! Thanks!

  • @milkamilkica1935
    @milkamilkica1935 2 ปีที่แล้ว +11

    love your videos

  • @bimblebom
    @bimblebom 5 หลายเดือนก่อน +1

    Never had a full grasp of lambdas until I watched this video! Thanks beautiful lady 🙂

    • @CodeBeauty
      @CodeBeauty  27 วันที่ผ่านมา

      Happy to help! 🥰

  • @tirushsanju2917
    @tirushsanju2917 2 ปีที่แล้ว +8

    Nice job madam. Thank you so much.🤩🤩🤩❤️❤️❤️

  • @glee21012
    @glee21012 2 ปีที่แล้ว +1

    The best explanation of Lammdas I have seen, not filled with computer science geek mumbo jumbo those guys love to spew.

  • @crazylongjumper95
    @crazylongjumper95 ปีที่แล้ว

    I have a biomedical engineering master degree, and I decided to learn C++ in the best possible way.
    Thank you so much for existing.

  • @sahilpawar3768
    @sahilpawar3768 6 หลายเดือนก่อน +1

    You cleared my basics very well thank you ..!

  • @marswalker4512
    @marswalker4512 ปีที่แล้ว

    @CodeBeauty You're really a great teacher. Thank you so much for the classes. Really helpful. Please keep on making videos. God bless you!

  • @whiteheart3190
    @whiteheart3190 2 ปีที่แล้ว

    Thanks aloooooooooooot for explaination , quiet and concentrated
    I hope you go forward

  • @nopecharon
    @nopecharon 2 ปีที่แล้ว +1

    Thanks for this awesome lecture!

  • @bomabeyoncebobmanuel9096
    @bomabeyoncebobmanuel9096 ปีที่แล้ว +1

    Nicely explained. Thank you very much!🥰

  • @satyajeetkumarjha1482
    @satyajeetkumarjha1482 2 ปีที่แล้ว

    Excellent stuff and you make things look easy.

  • @yashgarg6871
    @yashgarg6871 2 ปีที่แล้ว +1

    This is my first time visiting this channel and definitely learned something new, Thank you for the tutorial

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว

      you're welcome ☺️

  • @409_manohar6
    @409_manohar6 2 ปีที่แล้ว +12

    Hi mam

  • @iaroslavz2644
    @iaroslavz2644 ปีที่แล้ว +1

    Thank you very much. It was very good explained.

  • @Frammqooh1234
    @Frammqooh1234 2 ปีที่แล้ว +1

    GREAT video !! thank you again for another video !

  • @joebosah2727
    @joebosah2727 2 ปีที่แล้ว +5

    Thank you so much

  • @Farzadx-65
    @Farzadx-65 10 หลายเดือนก่อน

    Thanks. Very nice and clear teaching. From Iran 💐

  • @sabinanurak9633
    @sabinanurak9633 2 ปีที่แล้ว +6

    Very nice! 👍

  • @purduetom90
    @purduetom90 ปีที่แล้ว

    Your videos are great! Thank you!

  • @SilentReader972
    @SilentReader972 2 ปีที่แล้ว +1

    Thankyou so much...😍Good explanation...It will be helpful for my presentation..😄 please do more videos..

  • @learntocode5464
    @learntocode5464 2 ปีที่แล้ว

    Thanks, cool and simple explanation

  • @naanpizza3881
    @naanpizza3881 ปีที่แล้ว

    wow i never comment on videos but this simple explanation honestly blew my mind! thank you so much

  • @nvroshni1546
    @nvroshni1546 ปีที่แล้ว

    Thank you! it was quite helpful!

  • @BizTechLife
    @BizTechLife 2 ปีที่แล้ว +1

    I love your tutorials.😍 feedback: can yo please zoom in the code area? You can remove the folder and class structure views in VS. Thanks 😊 🙏 🤗

  • @chifuyuu1690
    @chifuyuu1690 2 ปีที่แล้ว +12

    3rd~!

  • @janmajaykumar131
    @janmajaykumar131 2 ปีที่แล้ว

    All of your videos are extremely important for the beginners like me. I learned a lot from these. Only one catch, beginners like me need a bit more practice problems and as well as a bit more theoretical explanation. Would you recommend some book on c++ which is very close to your lecture spirit or which you find suitable for learning cpp with practicing more? I will be grateful to you for your kind act.

  • @citoyennumero4434
    @citoyennumero4434 2 ปีที่แล้ว +2

    Des explications claires et simples ! Je vous remercie beaucoup

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว +2

      de rien ☺️🥰

  • @raychou8719
    @raychou8719 ปีที่แล้ว +1

    lambda confused me for almost 1 month and i always tried to not read thos code written by lambda untill i watched your video. Thanks so much.

    • @CodeBeauty
      @CodeBeauty  ปีที่แล้ว

      I'm so happy that it helped you ☺️ 🤗

  • @alokranjan
    @alokranjan ปีที่แล้ว

    you explained lambdas so simply and beutifully

  • @rounakchakraborty5176
    @rounakchakraborty5176 ปีที่แล้ว

    Good video. Learned a lot. Thank you❤.

  • @anga6275
    @anga6275 2 ปีที่แล้ว +5

    thank you! :)

  • @chandrashekharswain7593
    @chandrashekharswain7593 ปีที่แล้ว

    Thanks, Great Teaching..

  • @newvocabulary
    @newvocabulary ปีที่แล้ว

    Good explanation, thanks.

  • @petkopopov2823
    @petkopopov2823 ปีที่แล้ว +1

    exelent , learn match more then the course (expensive and to my lang) ! great thanks :)

  • @notmyopinion4981
    @notmyopinion4981 2 ปีที่แล้ว

    Hi, I am trying to learn C++ and did watch your learn c++ in 10h FULL COURSE video for beginners and I would like to start with lambda expressions next, since I need it for an assignment for next week(yes I know, lucky me you uploaded this just today :D). You have a lot of videos about different topics regarding C++, stuff that wasn't in your 10h C++ video, so I was curious if I need to watch any other videos before learning about Lambda expressions. It would mean a lot if you could make a playlist which does include all your videos about C++ in the intended order from easiest(beginner) to difficult(advanced). That would mean so much for people like me who want to know it all!!! :)

  • @B3rT286
    @B3rT286 2 หลายเดือนก่อน +1

    Thank you for an amazing explanation

    • @CodeBeauty
      @CodeBeauty  2 หลายเดือนก่อน

      🥰

  • @ChrisVideosGreek
    @ChrisVideosGreek 2 ปีที่แล้ว +1

    This book deserves more than a thank you! Really useful!!!

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว

      🤗💓💓

    • @NInJA_VEnOM_17
      @NInJA_VEnOM_17 11 หลายเดือนก่อน

      ​@@CodeBeauty❤❤❤❤❤❤❤❤

  • @hailemariameyayu9450
    @hailemariameyayu9450 2 ปีที่แล้ว

    you are briliant thanks.

  • @darkferiousity
    @darkferiousity ปีที่แล้ว

    Hi codebeuty love your videos thank you very much! Just a tip im not sure if it works in vscode, but in notepad++ you can highlight and hit cntrl+k to comment out all of that code. You can uncomment it by highlighing and cntrl+shift+k. Also you can overwrite a line by highlighting it and using paste directly on it with cntrl+v. If you want to select multiple lines with the cursor to tab several lines etc you can hold shift alt and left click down each line you want to have a multicursor really handy. :)

  • @xavierfrazao1469
    @xavierfrazao1469 7 หลายเดือนก่อน

    Very well explained

  • @BHARATHKUMAR-gr9km
    @BHARATHKUMAR-gr9km ปีที่แล้ว

    osm explanation and detailed info. good job thank you

  • @TKcKoucher
    @TKcKoucher ปีที่แล้ว

    Excellent content!

  • @MegaAtlus
    @MegaAtlus 2 ปีที่แล้ว +1

    Isn't it a coincidence? I just started using lambdas in C++. Thanks;)

  • @pablom2274
    @pablom2274 2 ปีที่แล้ว

    awesome! thank you!

  • @ABHISHEKSINGH-ib9ug
    @ABHISHEKSINGH-ib9ug 2 ปีที่แล้ว

    Thank you for this very informative and beautiful video, CodeBeauty

  • @rajendranm2204
    @rajendranm2204 ปีที่แล้ว

    Thanks for the content

  • @chrischoir3594
    @chrischoir3594 ปีที่แล้ว

    this is a great tutorial

  • @nastaranheidarysharifabadi4648
    @nastaranheidarysharifabadi4648 ปีที่แล้ว

    thanku it was really useful.

  •  2 ปีที่แล้ว

    saldinaaaaaaaaaaaaaaaaaaa! you are a great teacher. absolutely you are the best!!!!! thanks a lot!!!!!!!

  • @OzzFan1000
    @OzzFan1000 2 ปีที่แล้ว +1

    Damn that's a handy tool to have! Looks like Lambda expressions can get pretty complex pretty quick though.

  • @christiancarter255
    @christiancarter255 2 ปีที่แล้ว +1

    I like your pronunciation of "parameter". :)

  • @MaiNgocDoan1809
    @MaiNgocDoan1809 2 ปีที่แล้ว +1

    Well I love to see more topics about morden c++ like that

  • @zodiacdeggs1859
    @zodiacdeggs1859 ปีที่แล้ว

    Thank you from Beirut

  • @ghcguitar
    @ghcguitar 2 ปีที่แล้ว +1

    Hi Saldina! Do u have any video about encryption/decryption strings in c++?
    Great video BTW 😁

  • @AdityaG.
    @AdityaG. ปีที่แล้ว

    Thank you...!

  • @patrickmayer9218
    @patrickmayer9218 ปีที่แล้ว +3

    Just out of curiosity, what is the difference between the variables in the [ ] capture clause and the () parameters?
    And great job with the video, top notch stuff! :)

  • @s4ifbn
    @s4ifbn 2 ปีที่แล้ว

    thank you

  • @FJProject
    @FJProject ปีที่แล้ว +1

    7:02 - This kind of structures (classes) with overloaded operator() are called Functors.

  • @MartyAckerman310
    @MartyAckerman310 5 หลายเดือนก่อน

    So pretty much just like Python lambdas, they're used as "throwaway" functions. Thanks for the practical example.

  • @sreenadhpottipati9978
    @sreenadhpottipati9978 11 หลายเดือนก่อน +1

    Great, thank you CodeBeauty

  • @ahmetcelik6686
    @ahmetcelik6686 2 ปีที่แล้ว +7

    You are the best lady you should know that.

  • @theNeuo13
    @theNeuo13 2 ปีที่แล้ว

    Thank you

  • @abhishek-xv5ow
    @abhishek-xv5ow 2 ปีที่แล้ว

    much helpful :)

  • @shaharrefaelshoshany9442
    @shaharrefaelshoshany9442 2 ปีที่แล้ว

    Great contents

  • @nv9usb381
    @nv9usb381 2 ปีที่แล้ว +11

    ❤❤

  • @cavesalamander6308
    @cavesalamander6308 11 หลายเดือนก่อน

    C++ Builder?! Hi, colleague! Шt's nice to unexpectedly meet such a rare specimen who is still working with the С++ Builder. But I still use CB2007 (C++99) due to a lot of strange things in many last versions... The very last release looks more acceptable so perhaps it's time to move forward... Thank you for video.

  • @Negijicoder
    @Negijicoder 3 หลายเดือนก่อน +2

    Amazing..thx

    • @CodeBeauty
      @CodeBeauty  27 วันที่ผ่านมา +1

      Thank you too!

  • @arnaresh462
    @arnaresh462 ปีที่แล้ว +1

    Dear mam u r brilliant

  • @truecodeface
    @truecodeface 2 ปีที่แล้ว

    I am watching all the vides , thanks a lot about your programming productions, i would like to say that
    one of my important problem is still unsolved on your side.
    and that one is (MY REFUGEE REQUEST AND GETTING ME OUT OF AFGHANISTAN).
    again thanks a lot,
    your SUBSCRIBER Nasrullah Kuhzad from Afghanistan.

  • @ErezEl
    @ErezEl 2 ปีที่แล้ว +1

    Hey Saldina, you dont have by any chance video explaining iterators and object functions? Could really use your help on that..

  • @AM-ku9cw
    @AM-ku9cw 2 ปีที่แล้ว +1

    thank you Saldina for the perfect explination

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว

      you're welcome 🤗🥰

    • @NInJA_VEnOM_17
      @NInJA_VEnOM_17 11 หลายเดือนก่อน

      ​@@CodeBeauty❤❤❤❤❤❤❤❤❤❤❤❤

  • @duncanduncan3064
    @duncanduncan3064 2 ปีที่แล้ว

    Always nice video

  • @balazsstrahl6593
    @balazsstrahl6593 2 ปีที่แล้ว +1

    Hi Saldina!
    Is it better than writing code in the body of a simple for loop? This is what I never understood about sheep.
    Thanks for the reply!

  • @abhishekmane5955
    @abhishekmane5955 ปีที่แล้ว

    Thanks.

  • @SivananthanChelliah
    @SivananthanChelliah 7 หลายเดือนก่อน +1

    not sure if someone mentioned this ..
    the code
    [](int x) {
    if (x % 2 ) == 0 )
    ..
    else
    ..
    can be stored in a variable and then passed it to for_each function like this:
    auto func = [] (int x) { ... };
    std::for_each(v.begin(), v.end(), func);
    to make it clean