Function Pointers in C++

Patreon ► / thecherno
Twitter ► / thecherno
Instagram ► / thecherno
Discord ► thecherno.com/discord
Series Playlist ► thecherno.com/cpp
Thank you to the following Patreon supporters:
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
- Peter Siegmund
- Kerem Demirer
Gear I use:
-----------------
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K

Пікірлер: 358

  • @EmbeddedSorcery
    @EmbeddedSorcery5 жыл бұрын

    Pointer concept isn't hard. Syntax is just awkward and confusing imo.

  • @SankoshSaha_01

    @SankoshSaha_01

    4 жыл бұрын

    honestly that the problem; i forget it everytime!

  • @joestevenson5568

    @joestevenson5568

    4 жыл бұрын

    You have to read the syntax backwards

  • @Mateus.007

    @Mateus.007

    4 жыл бұрын

    int (*f(float (*)(long), char *))(double);

  • @Simon-jw1ww

    @Simon-jw1ww

    2 жыл бұрын

    if you mess it up it can be very dangerous too. One of the Syntaxes you have to understand before you try around. Thanks god c++ has smartpointers aswell.

  • @obinator9065

    @obinator9065

    2 жыл бұрын

    @@Simon-jw1ww function pointers have nothing to do with smart pointers. For something like this you should use lambdas and std::function.

  • @kinggore5229
    @kinggore52294 жыл бұрын

    Someone give this man a medal, pls.

  • @PythonPlusPlus
    @PythonPlusPlus5 жыл бұрын

    Who else is binge watching the playlist?

  • @TheGermanLPGaming

    @TheGermanLPGaming

    5 жыл бұрын

    yup.

  • @smurf123444

    @smurf123444

    5 жыл бұрын

    me!

  • @abdulalhazred5924

    @abdulalhazred5924

    5 жыл бұрын

    only you, I'm just looking for some specific stuff

  • @edencheung8468

    @edencheung8468

    4 жыл бұрын

    Mememememe

  • @RamiAwar

    @RamiAwar

    4 жыл бұрын

    > Netflix

  • @neo-babylon7872
    @neo-babylon78725 жыл бұрын

    Dude you're so good at explaining stuff. I was trying to understand function pointers for so long and all it took was this video. Also really good job on the threading video. Keep it up!

  • @tyreerobinson2016
    @tyreerobinson20164 жыл бұрын

    Your videos are absolutly amazing! You mix it up! Most youtubers just make you stare at a console through the whole course, and they only use their cursor to explain things. This playlist is well put together and well worth my time. Keep up the good work

  • @samsturdi
    @samsturdi5 жыл бұрын

    Hey dude, just wanted to let you know you are my go to for getting foundations of principles. You've helped me out several times. Thanks so much!

  • @vipulkamani6538
    @vipulkamani65384 жыл бұрын

    By far the best videos on C++. Thanks man! You just taught me overnight what my professor couldn't in 7 weeks.

  • @BlackJar72
    @BlackJar726 жыл бұрын

    A+++++ content! I've been wanting to learn more about function pointers.

  • @louarn

    @louarn

    5 жыл бұрын

    It's C++, not A+++++.

  • @richardlighthouse5328

    @richardlighthouse5328

    5 жыл бұрын

    @Louarn he meant grade: A+++++

  • @louarn

    @louarn

    5 жыл бұрын

    @@richardlighthouse5328 It was a joke

  • @vertigo6982

    @vertigo6982

    5 жыл бұрын

    Now on to function objects, and functors!

  • @diamaudixaudioltd.299

    @diamaudixaudioltd.299

    2 жыл бұрын

    needs more +'s

  • @vvanchesa
    @vvanchesa Жыл бұрын

    Found your c++ series now. To learn C++ and dive in quickly your videos are absolute great!

  • @alik250
    @alik2506 жыл бұрын

    This is the greatest coding tutorial series iIve ever seen. If only somebody as talented and knowledgeable about the subject would make similar styled tutorials for other coding languages, the world would be a much better place

  • @ETZERBEATS
    @ETZERBEATS3 жыл бұрын

    Your videos are amaizing, I was struggling with pointers and function pointers on my faculty projects and your tutorials made my life easier. Thanks and keep doing the good work.

  • @nuriya9000
    @nuriya90005 жыл бұрын

    Thank you so much!! I was revising cpp and I got stuck here. This really helped me a bunch. Definitely subscribing!

  • @miles7267
    @miles72674 жыл бұрын

    I think what makes you so much better than everyone else is the fact that you give examples of where you would actually use all the things you teach in code.

  • @shah.kairav
    @shah.kairav2 жыл бұрын

    Another nice use-case of function pointers could be system calls in OS development. You can talk about how the operating system stores an array of function pointer corresponding to each system call and that helps calling functions simply by indexing in that array.

  • @AswinJP
    @AswinJP4 жыл бұрын

    Very few people do such an excellent job at this. Thank you Cherno! :)

  • @masterproducts0
    @masterproducts06 жыл бұрын

    The simple explaination makes it very helpful! :) Thank you for this series and keep going like you do.

  • @NeoKailthas
    @NeoKailthas3 жыл бұрын

    This is like when you are half way through the semester and half the class dropped out or changed major.

  • @some_one

    @some_one

    3 жыл бұрын

    i just want to see how many are left in the end

  • @josuevargas7252
    @josuevargas72525 жыл бұрын

    Jesssss.......How incredible channel full of C++ special content.Thankyou very much.It's hard to find something like you here in my classroom....

  • @Fol2ey
    @Fol2ey3 жыл бұрын

    Dude. Your explanations are saving my life right now!

  • @AxElKo440
    @AxElKo4406 жыл бұрын

    Man, it's awesome, thank you so much for these lessons ♥

  • @greatbullet7372
    @greatbullet73726 жыл бұрын

    Im so in love with u that u continue this series

  • @ryanbinter2447
    @ryanbinter24475 жыл бұрын

    i love that you give a real useful example! ive seen bucky's videos and he never does this. he just tells you the idea and i guess assumes you know when to apply it. great job!

  • @reenamola2162

    @reenamola2162

    2 жыл бұрын

    bucky's tutorials are way better. cherno overcomplicates things. there's nothing hes done here that cant be done with just normal functions so he hasn't demonstrated on why u NEED to use function pointers.

  • @TheCodeHunter

    @TheCodeHunter

    Жыл бұрын

    @@reenamola2162 cherno goes into proper detail, Bucky just scratches the surface

  • @haven4512
    @haven45123 жыл бұрын

    Thanks for making these videos, they really help a lot!

  • @jun7452
    @jun7452Ай бұрын

    Man, that is absolutely crazy! Honestly, the more i learn about C++ the more i want to learn about the language, it's like you're fighting a Hydra, you cut one head but two grow as a replacement. I know these things aren't actually easy to get, and since there are like an infinite ammount of things you can do with this language, sometimes it just makes the programmer's life harder. But i think that this just shows that C++ is all about giving control to the programmer to do basically anything he wants to do, which i find it to be fascinating in it's own way. I'm aware that you won't read this comment since this video has been out for a long time, but i seriously am grateful you made this huge ass playlist bro! It's really really helping me to learn this language Thanks bro!

  • @annahakobian7371
    @annahakobian73715 жыл бұрын

    best c++ tutorials, thanks man

  • @ianpan0102
    @ianpan01023 жыл бұрын

    Brilliant content. I can't thank you enough, Cherno!

  • @ectoid6316
    @ectoid63165 жыл бұрын

    I like your videos, sometimes I just need a quick look into a subject and don't have the time to read the technical reference pages. So I just crank your videos double speed and blast my brain. :D thnx

  • @momentswithjireh3921
    @momentswithjireh39213 жыл бұрын

    Thank you Cherno for this super fantastic explanation!

  • @Katelomjaria
    @Katelomjaria3 жыл бұрын

    Great content! I was trying to write a homework and couldn't understand what I was doing wrong. after this video I could fix it immediately. VERY HELPFUL THANK YOU

  • @yang-z
    @yang-z4 жыл бұрын

    A function and a pointer to the function are different types. When assign a function to a variable, func converts itself to a pointer implicitly, just as you mentioned. On the other hand, we can use a ptr to a func to "interact" with "operator ()" just as func itself, just because the "()" is overloaded implicitly, I guess. Actually, a function is able to be "quoted" by reference with the original type rather than a pointer. But when you want to store several functions to a array to do a batch call, the pointers are stored.

  • @jakobhuetter
    @jakobhuetter3 жыл бұрын

    Love your videos! Helping me a lot with my university stuff!

  • @sunilpatro1047
    @sunilpatro10474 жыл бұрын

    Awesome explanation. I did search a lot but couldn't understand. But now all my doubts are clear after watching this video. Great content.

  • @NeZversSounds
    @NeZversSounds4 жыл бұрын

    I learned a similar thing in GameMaker and used for Finite State Machine, where state function is assigned to a variable that is called each game frame.

  • @onyinyechichukwuma689
    @onyinyechichukwuma6892 жыл бұрын

    The best C++ explanations EVER! Thanks!

  • @DiogoManteu
    @DiogoManteu10 ай бұрын

    Such a great explanation with examples.

  • @figurehe4d
    @figurehe4d6 жыл бұрын

    excellent video. well explained. function pointers seem useful but the way I've been exposed to them so far only highlights the confusion!

  • @DanielLiljeberg
    @DanielLiljeberg Жыл бұрын

    This brought back memories... I remember back in the early 2000 when I added a console to my game engine and hooked up function pointers to strings to be able to call those functions from the console :P

  • @Vermilicious
    @Vermilicious4 жыл бұрын

    Passing functions is super useful sometimes. It's a concept I first saw using JavaScript. It's really cool that you can do it in C++ (for a while) now.

  • @MohdFaisal-ie6mo
    @MohdFaisal-ie6mo6 жыл бұрын

    Keep up the good work. KZread need experience coders like you.

  • @santhoshnagarajs3489
    @santhoshnagarajs34896 жыл бұрын

    finally i understand why there is need for function pointers!! thank you .

  • @Hasansaid51
    @Hasansaid513 жыл бұрын

    That explanation at 1:04 just clicked in my head and I didn’t even watch the rest of the video. Thanks brotha 🙏🏾

  • @eventhisidistaken
    @eventhisidistaken3 жыл бұрын

    Function pointers were the precursors to OO. On rare occasion, I still use function pointers ( for dll support) , but really, you should avoid them when they are not necessary, not just because of the obtuse syntax, but because they are too loose - which means intractable bugs. I have seen people essentially reinvent c++ using #define and function pointers. I'm sure they thought it was really clever, but they were the only people willing to maintain the code. As soon as they leave the project, the first thing that happens is others toss their unmaintainable garbage code into the bit bucket and start over.

  • @hlrbBrambleX
    @hlrbBrambleX2 жыл бұрын

    I just realized this is how callback function works. Amazing!

  • @laurentiudobrescu9045
    @laurentiudobrescu90456 жыл бұрын

    Good work ! I need this video , it's awesome !

  • @samuelmaucaille702
    @samuelmaucaille7025 жыл бұрын

    Bro you're a fantastic teacher! thanks a lot!

  • @frederickmloka5454
    @frederickmloka54544 жыл бұрын

    Thanks for demystifying subject

  • @muhammadarslanrana942
    @muhammadarslanrana9423 жыл бұрын

    with this we can implement map(), reduce(), filter() functions as well.

  • @SaifuddinEvloev
    @SaifuddinEvloev Жыл бұрын

    Function pointers allow us to use the concept of higher order function map, if the map function is too complex, then lambda functions won't be readable. So I think that function pointers are still an important part of C++.

  • @duchaolv5876
    @duchaolv58762 жыл бұрын

    Every time I want to know something about modern c++, I come here. Good job Cherno!

  • @NeoKailthas
    @NeoKailthas3 жыл бұрын

    "Gentle introduction" lol 😆

  • @nandukrishna8142
    @nandukrishna81422 жыл бұрын

    That helped me so much in writing my own game engine with glut window and opengl

  • @danielc4267
    @danielc42675 жыл бұрын

    Great content. Thank you cherno

  • @isaiaskaung8856
    @isaiaskaung88565 жыл бұрын

    Thank you so much for showing new tricks.

  • @naughtrussel5787
    @naughtrussel57876 жыл бұрын

    Thank you for cool vids. Plz don't stop.

  • @leducphuclong
    @leducphuclong19 күн бұрын

    Thank you so much !! Great Teacher !!

  • @LAB_XI
    @LAB_XI3 ай бұрын

    Great as usual 🔥

  • @avnishs.2514
    @avnishs.25144 жыл бұрын

    Amazing video! Helped me understand better

  • @WhosTheBossHD
    @WhosTheBossHD5 жыл бұрын

    In C# i use Action for function pointers. Function pointers are great for Publish/Subscription type of projects.

  • @iteratedofficial
    @iteratedofficial2 жыл бұрын

    Probably the best c++ tutor on youtube

  • @Ebiko
    @Ebiko2 жыл бұрын

    i personally love function pointers. I regulary store them in hashmaps , to call a similar, but different funktion every time. Like when i create elements of some sort, but the functions are only similiar in theory, but the execution is different, even if the result is the same. And at this point, i create a HashMap, calling the functions by keyword, with needed parameters. Thats so cool, it really helps me keep my functions organized, and i can add another element to the Map easily at any point For example when i want to parse Network data from another program, or via Rest APIs

  • @mms0537
    @mms05373 жыл бұрын

    I respect you dude

  • @rajeevsawant2281
    @rajeevsawant22815 жыл бұрын

    Excellent Video's. Thank you. It would be very helpful if you could have an few famous problems related to the topic and maybe a solution video .

  • @joseernestoguerrerocueva9916
    @joseernestoguerrerocueva9916 Жыл бұрын

    mate i fucking love your series

  • @VasaMusic438
    @VasaMusic4385 жыл бұрын

    Great video, again !!! Thanks !!!!

  • @charr6108
    @charr61082 жыл бұрын

    OMG! did i just learnt lamda and function pointer in 10 minutes... awesome!

  • @chsu_
    @chsu_ Жыл бұрын

    Thanks for your video!

  • @zyulaikhaerhad
    @zyulaikhaerhad3 жыл бұрын

    Thank you!! You just saved me and my assignment from the due date

  • @gunrunjk
    @gunrunjk5 жыл бұрын

    I always enjoy your video.

  • @qy4247
    @qy42473 жыл бұрын

    Really good tutorial. Thx from China ❤

  • @hishamsomroz6913
    @hishamsomroz69133 жыл бұрын

    finally a channel whose videos i dont have to watch at 1.5x or 2x

  • @tokita1230
    @tokita12306 жыл бұрын

    I hope that you'll talk about method pointers in the next video and how you can use them without the standard library.

  • @hankstalica1922
    @hankstalica19224 жыл бұрын

    Excellent vid.

  • @diegomora997
    @diegomora9972 жыл бұрын

    Dude, you make me feel more exited about computer science

  • @alexsece
    @alexsece5 жыл бұрын

    Great job!

  • @jannesopanen8032
    @jannesopanen80323 жыл бұрын

    This is very handy matter in C++. I can pass a pointer as a parameter, pointer to function which I want to be in charge of handling values. :D

  • @Ash-ei9ku
    @Ash-ei9ku6 жыл бұрын

    Clean cut

  • @AngelTaylorgang809
    @AngelTaylorgang8094 жыл бұрын

    Start a data structure series please, greetings from Texas

  • @phantomstriker7996
    @phantomstriker7996 Жыл бұрын

    The name says it all. It points towards a function instead of a variable.

  • @danklabunde
    @danklabunde4 жыл бұрын

    I have always struggled with pointers but this video actually turned on a lightbulb for me XD. I know function pointers are different but the "pointer theory" if you will makes much more sense now!

  • @zoronic6248
    @zoronic62484 жыл бұрын

    I know it's a bit late, but GODDAMN THAT HAIRCUT MAN!!!!! Everyone looks good with a fade and part

  • @trongnhantran3358
    @trongnhantran3358 Жыл бұрын

    This blow my mind!!

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd5 жыл бұрын

    Really Fantastic Explanationss...Great............PLEASE DO Post Videos Related to Design PAtterns and DATA Structure.

  • @daveski084
    @daveski0845 жыл бұрын

    He's so cute, makes learning C++ that much better lol.

  • @joseponce6250
    @joseponce62502 жыл бұрын

    thank you!!

  • @lucianbetke
    @lucianbetke2 жыл бұрын

    Cool mister. A good explanation.

  • @Simon-fu8sd
    @Simon-fu8sd2 жыл бұрын

    I just find this so cool

  • @JesseLeeHumphry
    @JesseLeeHumphry2 жыл бұрын

    I've been working with UE4 and dispatchers seem to work based on function pointers, but I was never sure what a function pointer _was_ or how it was _written_ because UE code is so....'nebulous' isn't the right word, it's just kinda hard to track stuff down is all. And this video got me caught up. A+ stuff right here.

  • @abhisheksa6635
    @abhisheksa66359 ай бұрын

    Man have been coding for a while, even that passing function inside another function using function pointer is sort of a overkill but yeah that's a way and can be used. I am majorly from a C background and mostly in my code we have seen the function pointer array but this was next level, the lambda is not known to me much, will go through and understand it.

  • @voiddeepstorage6533
    @voiddeepstorage65332 жыл бұрын

    you should do a video about using variadic templates function pointers, its a really cool topic.

  • @user-rk9zx3lt8k
    @user-rk9zx3lt8k8 ай бұрын

    this lesson which involves some many technical things such us auto, vector, typedef, function pointer, reference, even iterator inside

  • @jsnmad
    @jsnmad3 жыл бұрын

    C++ Callbacks! Nice

  • @balaramprajapati8870
    @balaramprajapati88702 жыл бұрын

    very good explanation

  • @cavelinguam6444
    @cavelinguam64444 жыл бұрын

    really awesome

  • @zackjandali
    @zackjandali5 жыл бұрын

    @TheChernoProject I've never seen that kind of for loop! I kinda understand what it does: for (every index in : this array) do this; I'd like to see what other ways that could be used! Could you do a short video, or dedicate part of a video to explaining that. If you've already done that, can you show me where to look? :) Thanks for the vids, they're so helpful

  • @dpalmer4588
    @dpalmer45885 жыл бұрын

    So, like nested functions, essentially? very cool

  • @adocarpel7770
    @adocarpel77705 жыл бұрын

    many thanks

  • @programthis3805
    @programthis38058 ай бұрын

    so cool!

  • @2012Misanthrope
    @2012Misanthrope5 жыл бұрын

    Great C++ videos! Much appreciated. Is that an XPS 13 your using?

  • @user-rk9zx3lt8k
    @user-rk9zx3lt8k8 ай бұрын

    this is the best

  • @andreskoszutski4364
    @andreskoszutski43642 жыл бұрын

    .... in the future... Just kidding. I find your series extremely useful.