References in C++ Explained

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

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

  • @codebreakthrough
    @codebreakthrough  Год назад +2

    Check out the hands on guide - ruclips.net/video/GVEcLAX7ogk/видео.html
    Get notified of my upcoming C/C++ Courses - www.codebreakthrough.com/upcoming-c-cpp-courses

  • @raviel_0422
    @raviel_0422 4 года назад +40

    Thanks Caleb, I've been following your C++ Tutorial way back 2019 because you are a great teacher, you saved me a lot.

    • @rohanarya5400
      @rohanarya5400 4 года назад +1

      I've been looking for a follow up to his C++ course. Any suggestions?

    • @siddharthraghuveeremadaboi2901
      @siddharthraghuveeremadaboi2901 4 года назад

      @@rohanarya5400 get working on eulerprojects Github and Codeforces. You could get a reading on the book 'code'.

  • @facent523
    @facent523 4 года назад +92

    The fact that this guy is currently carving our way for our future just for us is priceless

    • @retrace
      @retrace 3 года назад +1

      Fax

    • @du4lstrik3
      @du4lstrik3 Год назад

      If this was your future, YOU would carve it for yourself.

  • @valkyrja7280
    @valkyrja7280 4 года назад +155

    *sees an asterisk in code*
    My brain “OHHH HEEELLLLLLL NOOOOOO”

    • @Italy-rj2eb
      @Italy-rj2eb 3 года назад

      @Messiah Atticus Hehe nice scam

    • @capitaopacoca8454
      @capitaopacoca8454 3 года назад +3

      You described my last week so well.

    • @ethangold4900
      @ethangold4900 3 года назад +1

      I've been like this since C
      I'm here to stop my confusion about pointers

    • @AbhishekBM
      @AbhishekBM 3 года назад +1

      I can hear your comment

  • @wendyargyle2333
    @wendyargyle2333 11 месяцев назад

    This is the first time any C++ concepts really started to "click". Bro, keep up the good work! Thank you for your help!

  • @llllllllll5119
    @llllllllll5119 2 года назад +2

    I've been struggling for weeks trying to understand this and pointers and you literally got it to click in 15mins. You're amazing, subscribed.

  • @deivid-01
    @deivid-01 2 месяца назад

    Every time I have a technical interview, I watch this video again. But this time was different. Something clicked in my mind 🤯 Thanks, Caleb! I've followed you since you started the channel, and I've learned so much from you. Thanks a lot, man!

  • @skypuff
    @skypuff 4 года назад +29

    Did you play the clip? 😂😂
    Man I love his vids. You can't be bored to death.

  • @tsupi7056
    @tsupi7056 4 года назад +27

    Commenting for Yt algorithm

  • @MrMcgrizz
    @MrMcgrizz 6 месяцев назад +1

    Thanks for the great explanation! I am new to C++ and needed to understand this, and also the part after 13:00 was very informative and useful!

  • @nilupulperera
    @nilupulperera 4 года назад +15

    Wow, Caleb! Thank you so much for starting this series. I am in the middle of your first series of C++. That series is really awesome. I like your teaching style. You are a great teacher. I found you concluded the previous series a little short. I am delighted to see this intermediate series is started. Kindly continue this series. Your series is really helpful.

  • @mordicai4296
    @mordicai4296 3 года назад +4

    Thank you Caleb! I'm in a C++ bootcamp and your channel has taken me from failing to an A!

  • @AKTSR444
    @AKTSR444 3 года назад +3

    this is great. Now I got it. My prof sucks. He mixed pointer and ref and totally confused us.

  • @cruellnat
    @cruellnat 4 года назад +25

    Because it is very simple... which is why we need to talk about it. 😂

  • @skypuff
    @skypuff 4 года назад +8

    This was a wonderful video. I'll be patiently waiting for more.

  • @AK-vx4dy
    @AK-vx4dy 3 месяца назад

    I didn't expect that C++ lesson on blackboard can be so good, excellent job

  • @Diamond_Hanz
    @Diamond_Hanz 4 года назад +4

    Crazy. I was reviewing this earlier! Keep it up!

  • @magicdragon9621
    @magicdragon9621 3 года назад +4

    Wish I found this video sooner. After 4 hours of trying to understand this concept I finally get it haha. Thanks!

  • @RakeshSharma-p2o
    @RakeshSharma-p2o 3 месяца назад

    You're truly the best coolest teacher i have ever seen in my life

  • @nicholasmaniccia1005
    @nicholasmaniccia1005 Год назад +2

    Nice, idk if you explained it really well or if after playing with references and coming back to an explanation was the final thing to make me understand this concept, but I feel like I finally get it.

  • @THATREISGUY14
    @THATREISGUY14 9 месяцев назад

    Love your teaching method and your comedy sprinkled throughout! Thanks man!

  • @ChadTower
    @ChadTower 2 года назад +3

    Love this video, he really does explain it far better than the course material in the 300 level undergrad course I'm currently taking.
    Also... LEEEEEEEEROYY JENNNNNNNNKINS

  • @silentcal275
    @silentcal275 7 месяцев назад

    Thanks for this. POinters feels like a game of inception in my head. Especially when it comes to pointers to pointers

  • @griffontheorist6975
    @griffontheorist6975 24 дня назад

    I was struggling for way too long why "int& myVar" and "int &myVar" popped up inconstantly. Thank you so much for pointing this out

  • @azrflourish9032
    @azrflourish9032 2 года назад

    the way you teach is very effective and easy to understand. Thank you!

  • @anon343
    @anon343 3 года назад +1

    Thank you for explaining the memory efficiency of references, I like to know why code is "best practise"

  • @pacocarrion7869
    @pacocarrion7869 7 месяцев назад

    Few basic examples to remember:
    void work (x){return x;} // No reference
    void work (&x){return x;} // Argument reference
    void& work (x){return x;} // Function reference
    void& work (&x){return x;} // Argument + Function reference
    int& a=b; reference variable to variables
    int&& ref=work(x); reference from function (without reference) to variable
    int& ref=work(x); reference from function (with reference) to variable

  • @heshansandeepa6387
    @heshansandeepa6387 3 года назад

    This can't be explained better than this. Top notch

  • @mykalesalad
    @mykalesalad 2 года назад +1

    This was incredibly helpful, thank you for the detailed explanations!

  • @ebrar2536
    @ebrar2536 12 дней назад

    for the first time ever i actually understood the references

  • @AshShawwa
    @AshShawwa Год назад

    After watching this video I have two things to say: 1 - thank you, your explanation is heaven sent and 2 - after your Leeroy Jenkins comment, I gotta ask. You play WoW, because if you do were gaming 😂

  • @isaacchen3857
    @isaacchen3857 3 года назад

    "Maybe that's a bit more depth than you need for this introductory video"
    Nope. Not for me, at least. That last detail you went over was super helpful. Thank you for the great video!

  • @akarcel
    @akarcel 4 года назад +4

    Best caleb in the world 👍❤️

  • @shashanksharma21
    @shashanksharma21 3 года назад

    this is awesome! thank you so much for creating these illuminating lectures !

  • @mellow_frequencies
    @mellow_frequencies 2 года назад +2

    You make learning this like 10 times more fun, i apprecieate it!

  • @Basedmarv
    @Basedmarv 3 года назад

    10:35 troll joke made me chuckle out loud, great video!

  • @Ab-zq2ye
    @Ab-zq2ye 4 года назад +2

    Young and Intelligent Your the best teacher Caleb.
    From Ethiopia

  • @monkeyrobotsinc.9875
    @monkeyrobotsinc.9875 Год назад +1

    You are a great instructor.

  • @okkami676
    @okkami676 4 года назад +1

    QUESTION: 7:58 to 8:04....doesn't "int &x" at the function refer to the 'address' of 'a' rather than the 'value ' of a ( ie '5')? That is, when we call the function, aren't we passing in the "address of a" rather than the "value of a"?

    • @masheroz
      @masheroz 3 года назад

      How I think of it working is: when you call work(a), internally the program is saying int & x = a; and then doing the things on x. I need to retrain my brain on how the function arguments work from my Java days, but the 'int' is always correct, and says that the function expects an integer. If it is 'int & x', it will get a reference to an integer, and if it is 'int * x' it will get a pointer to an integer.

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

    You're literally the best, thank you so much!

  • @StopRemindingMeOfThoseDays
    @StopRemindingMeOfThoseDays 3 года назад +1

    So basically a reference is like a desktop shortcut for an exe application.

  • @lucasmuller7179
    @lucasmuller7179 2 года назад

    "But no... you just got trolled" I almost spit my coffee

  • @harismasoom6634
    @harismasoom6634 3 года назад

    i am in love with your teaching style.

  • @jakubdzwigacz4563
    @jakubdzwigacz4563 2 года назад

    so far the best explonation i could find

  • @marcellodelfiore1361
    @marcellodelfiore1361 Год назад

    this video is actually fantastic, thank you so much, i appreciate your work, keep it up and good luck with everything :D

  • @SebleBeyene-jp8hp
    @SebleBeyene-jp8hp 7 месяцев назад

    I hate this dude when i was noob but still want to see this dude

  • @Ajcmaster
    @Ajcmaster 3 года назад

    Great explanation Caleb! Awesome. Way to go!

  • @dylanjackson7325
    @dylanjackson7325 10 месяцев назад

    concise and clear. thanks dude

  • @jpenneymrcoin6851
    @jpenneymrcoin6851 2 года назад

    hey beginners - if you want a simple explanation, here it is.
    when you name a variable, the compiler makes a table with that variable name in one column and a number in another column.
    the number is what you get when you use a reference.
    the number is an address in whatever memory space is in use - you don't have to worry about that, the linker handles physical placement.
    once you have the number stored, you can write to or read from memory.
    now, slightly more complex is that you can also do pointer math and move around in memory on your own, reading and writing things that may not have a variable name associated with them. So you can say "go to the spot where variable a is, then advance 2 bytes in memory and write a 3 there"
    that allows you kind of direct access to the memory space.
    there you go - 15 minutes saved for those of you who don't need so much hand holding.

    • @draqaah
      @draqaah Год назад

      He what did he type looks 8 or & idk what he type

  • @jacobpickos733
    @jacobpickos733 2 года назад

    Bro. You're a beast. This is just what I was looking for.

  • @SKMINSARR
    @SKMINSARR 3 года назад

    I like the technique of your teaching. Really it's a great tutorial man

  • @navaerick86
    @navaerick86 2 года назад

    you explain things the best ive seen. thanks

  • @arkapravaghosh4594
    @arkapravaghosh4594 4 года назад +1

    This was such a great video all sorts of confusion got cleared so well. Thanks brother.

  • @smrtfasizmu6161
    @smrtfasizmu6161 2 года назад

    I got problems but I had problems with understanding reference. It seems to me like reference is sometimes treated as a memory address but then you can also treat them as normal variables. When it comes to pointers it is clear when that you always have a memory adress and if you want to see what is on that memory address, or change what is on that memory address, you deference the pointer by putting a * in front of the pointer. These references are a little bit confusing because they sometimes act as pointers and they sometimes act as normal variables. I don't see why I can't just replace references with pointers. For instance the function swap would go like this.
    void swap(int* a, int* b) {
    int temp = *a;
    *a = *b;
    *b = temp;
    }
    Also, when you use pointers as arguments of a function you know you are passing memory addresses to the function so you expect that the function might change the variables whose addresses you are passing. I find pointers more clear and understandable than references.

  • @iutubgugal5566
    @iutubgugal5566 3 года назад

    Thank you! This was well detailed and clear.

  • @TomtheMagician21
    @TomtheMagician21 2 года назад

    This is a great video and I understand references and pointers now (from your other video).
    However, I could change the variables that were passed in as parameters even without references.
    For example (in C++ still because I've been learning for 2 days so far lol):
    void Swap(int x, int y)
    {
    int temp = x
    x = y
    y = temp
    }
    And that works fine so 🤷

    • @flyingspaghettimonster8612
      @flyingspaghettimonster8612 2 года назад +1

      its not the same as he said in this case x and y would be a copy of the values you passed, the variables outside the fuction will still be the same even if you change the values in x and y

    • @TomtheMagician21
      @TomtheMagician21 2 года назад

      @@flyingspaghettimonster8612 Oh ok thank you, would I need to create a reference inside the function then and then change the value of that reference? That's pretty cool

  • @jason27kboy
    @jason27kboy 4 года назад

    Just finished the last series and I really hope this is the start of part 2

  • @gremjo8409
    @gremjo8409 3 года назад

    Great video! Exactly the explanation I was searching for

  • @ddimwhite4638
    @ddimwhite4638 4 года назад +2

    Bravo! Thank you.

  • @Captain_Rhodes
    @Captain_Rhodes 3 года назад

    Nice video. I like how you dont write any code on a computer. makes it better

  • @aberateklehaimanot9804
    @aberateklehaimanot9804 4 года назад

    Thanks Caleb.you are an amazing teacher.

  • @erfanelmtalab3426
    @erfanelmtalab3426 4 года назад

    I love the way that you write & diffrent in every time😂😂

  • @marcusantenor793
    @marcusantenor793 11 месяцев назад

    there is no love it button, so i will type. Love it, thanks a lot.

  • @juniorlucival
    @juniorlucival 9 месяцев назад

    A reference (ref) does not occupy memory space, cannot be null, and cannot be modified. Attention!!!

  • @christianalvarado528
    @christianalvarado528 Год назад

    4:28 I actually thought all this time that this were 3 completely different things. And it's just a variation in writing.

  • @xcalimburdeveloper3929
    @xcalimburdeveloper3929 4 года назад +5

    Wait, is this C++ series part 2

  • @thatgirl7650
    @thatgirl7650 2 года назад +1

    Thank you so much ✨

  • @ARANDOMOPENAIUSER
    @ARANDOMOPENAIUSER Год назад

    1:41
    9:40

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

    you make it sound easy

  • @higiniofuentes2551
    @higiniofuentes2551 Год назад

    Thank you for this very useful video!

  • @AFourEyedGeek
    @AFourEyedGeek 2 года назад

    Nice! Thank you for this.

  • @ddkan_9982
    @ddkan_9982 2 года назад

    just perfect ! thank you!!

  • @TomtheMagician21
    @TomtheMagician21 2 года назад

    At 13:30, what if you did like &b = &c? Would that work or can you only assign b directly and not it's address?

  • @krup9898
    @krup9898 8 месяцев назад

    Thank you very much. God bless!!!

  • @audiodiwhy2195
    @audiodiwhy2195 8 месяцев назад

    Good tutorial. Thanks.

  • @NikhilSharma-jj6bx
    @NikhilSharma-jj6bx 3 года назад

    Dude you are on fire today.

  • @Meridian-lk2fo
    @Meridian-lk2fo 2 года назад

    Very well explained!

  • @DonaldMurf
    @DonaldMurf 3 года назад

    Thanks man. You helped me a lot.

  • @mohamedeljabri4970
    @mohamedeljabri4970 2 года назад

    Frankly it is very difficult to give my comments to anybody but you deserved highly top and your flag is great
    I am still can't find thanking words for long time being misunderstood.

  • @skypuff
    @skypuff 4 года назад +1

    This is FUN-THEN-MENTAL (fudamental)

  • @karimmuhammad7051
    @karimmuhammad7051 2 года назад

    this is mean, reference is not a new variable refer to specific place in memory?
    it is the variable which it refer to??!!
    so this is not add on size of memory one place!
    right?

  • @tomitomi7941
    @tomitomi7941 Год назад

    Great video, thank you man

  • @hamdansiddiqui3294
    @hamdansiddiqui3294 6 месяцев назад

    exactly what i looking for!

  • @ECEPAZHANIMURUGANSIVAP
    @ECEPAZHANIMURUGANSIVAP Год назад

    your r great... such a simple and clear explantion /////

  • @Phoez12
    @Phoez12 2 года назад

    Dude you own.

  • @7s9n
    @7s9n 4 года назад

    Thanks caleb 💛

  • @Mohamed-Maghrebi
    @Mohamed-Maghrebi Год назад

    Thank you well explained

  • @keshavjha2641
    @keshavjha2641 4 года назад +1

    Hey can you make something on typescript

  • @fake_rabbi
    @fake_rabbi 3 года назад

    Thanks Caleb

  • @nicolascrespo4643
    @nicolascrespo4643 2 года назад

    Thanks a lot!

  • @msingizanengwenya6707
    @msingizanengwenya6707 3 года назад

    IS THE USE OF "&" SAME AS WHEN YOU USE IT I EXCEL?

  • @petarvico1757
    @petarvico1757 3 года назад

    Great video!!!

  • @uttamkarmakarece3534
    @uttamkarmakarece3534 3 года назад

    Well explained

  • @sadatshahriar2090
    @sadatshahriar2090 3 года назад

    This is awesome !

  • @OpheliaSHolmes
    @OpheliaSHolmes 3 года назад

    Thanks for the tips

  • @jeyosman1
    @jeyosman1 Год назад

    how can we use pointer to reference like this (int *& a)

  • @marvet9573
    @marvet9573 2 года назад

    Yeah bro, if I make any serious amount of success, you're getting a fat check. You deserve my money more than my university does.

  • @codingwithflavio8534
    @codingwithflavio8534 2 года назад

    thank you for this

  • @kelolettek3927
    @kelolettek3927 3 года назад +1

    you look like someone i know in france

  • @mrmoody915
    @mrmoody915 6 месяцев назад

    Your the best bro