Learn C++ With Me #14 - References (&)

Поділитися
Вставка
  • Опубліковано 8 лют 2025

КОМЕНТАРІ • 43

  • @elwizko
    @elwizko 3 роки тому +18

    We just learned about references yesterday in class. So timely...thanks Tim

  • @softwhere07
    @softwhere07 3 роки тому +8

    I am loving these c++ videos. Everytime you post them I take out my phone and the c++ ide on it and I follow along with it. It's very interesting stuff. I honestly look forward to every new one that comes out. Keep it up. And keep them coming!!!

  • @yxlxfxf
    @yxlxfxf 3 роки тому +25

    The error at 11:13 isn't because "NULL" is a special type, NULL is just a macro that is usually defined to be 0, you get the error because a non-constant reference cannot be initialized with an rvalue (a literal 0 in this case).
    For example the following will compile:
    bool const &x = NULL; // same as bool const &x = 0;
    Also, what you talked about in this video is technically called "lvalue reference" (there are also rvalue references)

    • @rayjonas9355
      @rayjonas9355 3 роки тому

      @Kobe Shepard yup, I have been using InstaFlixxer for since november myself =)

    • @yxlxfxf
      @yxlxfxf 3 роки тому +5

      totally not a bunch of bots

    • @SP-bb2ni
      @SP-bb2ni 3 роки тому

      Yep... A totally normal human, non-robotic conversation. Nothing special

    • @Pompomatic
      @Pompomatic 2 роки тому

      Make sure to report so we get rid of them

  • @dimasveliz6745
    @dimasveliz6745 3 роки тому +3

    C++ is a language that needs to be clarify when is being taught, so THANKS for doing that! This language is awesome and extremely powerful, but the internet made of it a Swiss knife

  • @michaelsilvers1260
    @michaelsilvers1260 8 місяців тому

    Tim considering I only see these videos go into 20 something, and this one is 3 years old.. I hope you still make these videos in a different album or something. You are such a great teacher, or at least for me. The way you helped visualize this in my brain with your words made it so simple to understand. When my professor went over references I was so lost. But picturing the boxes really helped me understand basically immediately.

  • @AlanMitchellAustralia
    @AlanMitchellAustralia 3 роки тому +1

    Great videos Tim. Very well thought with easy to follow and intuitive examples :) I've come from python and just starting to learn C++. I've watched all the videos in this series so far, love your simple and consise training style, especially how you demonstrate what *doesn't* work and why you might get error messages etc. Personally I find this incredibly valuable - I often find there is nothing better than being aware of the *incorrect* practice to reinforce what is *correct* . If you can apply your simple and intuitive approach all the way through to classes, inheritance, vectors, memory management, architecture etc, I think you'll be on to a winning series :)

  • @736939
    @736939 3 роки тому +7

    Dear Tim can you show us please how to make basic system programs with C++ because students believe that learning C++ in 2021 waste of time and it's only good for solving "competitive programming" tasks and game development. Thanks!

    • @egehurturk6209
      @egehurturk6209 3 роки тому +1

      It's definitely not a waste of time.

  • @Jack-ht3fr
    @Jack-ht3fr 3 роки тому +1

    this is useful you can make an reference to an object of the class as one of the parameters of function and then in the function you change the object's variables
    cool stuff

  • @CodeVisualization
    @CodeVisualization Рік тому

    Thank you, this made me finally understand :D

  • @aaravgp1332
    @aaravgp1332 3 роки тому +1

    4th, I have been waiting for pointers, referrences and vectors for sooo long

  • @nedjmounettari8336
    @nedjmounettari8336 3 роки тому

    Very great simple lesson

  • @subee128
    @subee128 2 роки тому

    Thanks

  • @rezahajivand7498
    @rezahajivand7498 Рік тому

    Hello . Thank you

  • @yourdadsbestfriend7101
    @yourdadsbestfriend7101 3 роки тому +1

    yessssssir

  • @Didanihaaaa
    @Didanihaaaa 3 роки тому +2

    it is like entanglement in quantum physics! &b=a :)

  • @shawnbeans7389
    @shawnbeans7389 3 роки тому

    nice hoodie tim

  • @Aliyyiakbar
    @Aliyyiakbar 2 роки тому

    Makes sense on onlime games where you example have a sharing money with your teammate and when you use the money, it decreases both of yours. Other than that never heard that useless function.

    • @Jeff--vq4zb
      @Jeff--vq4zb Рік тому

      Well, in an online game, each player would have their own copy of the game running on their system, and changes would be made be sending network traffic. References are just a way to directly access something. I don't yet understand everything. All I know is that I tried to write a program once, and I used SDL2 for loading my graphics. I needed references and pointers to access the images from memory.

  • @andreaspatounis5674
    @andreaspatounis5674 3 роки тому +1

    What's the topic of the last c++ tutorial is going to be, I mean are you going to make as much tutorials in c++ as you have made in python

  • @rabiumuhammedeffect423
    @rabiumuhammedeffect423 3 роки тому

    A big up from Ghana Africa

  • @glassworkssundrops
    @glassworkssundrops Рік тому

    When you have a form for a client to fill out s/he needs to have a label other than 'a' such as &name. Then we I go to use the variable name elsewhere I am using the correct information.

  • @mrgamer-lu1im
    @mrgamer-lu1im 3 роки тому

    we will learn about the vector and list library

  • @mrgamer-lu1im
    @mrgamer-lu1im 3 роки тому

    i think we will cover memory allocation soon either with malloc or new?

  • @lbproductions6215
    @lbproductions6215 3 роки тому

    Note: the references in this video are lvalue references.
    You can also define rvalue references.
    The difference is basicly that lvalue references are for lvalues and rvalue references are for rvalues.
    Also NULL is a macro from c and should not be used anymore. With pointers you can use nullptr instead.
    Lvalue reference:
    int a = 3
    int &b = a;
    Rvalue reference:
    int &&a = 3;

  • @valencehockey1668
    @valencehockey1668 3 роки тому

    Yes!

  • @MixedByTheScientist
    @MixedByTheScientist 5 місяців тому

    So I’ve noticed that conventionally, it is written as ‘type& var’ vs ‘type &var’. I know they’re both exactly the same and it doesn’t matter but is there a reason why the former style is more preferred?

  • @mrgamer-lu1im
    @mrgamer-lu1im 3 роки тому

    the reference converts it to a pointer that is just the address

  • @AAA999XYZ
    @AAA999XYZ 3 роки тому

    Alright the lesson makes sense but I don't see any conditions in which this would really be useful

  • @rockoncode8955
    @rockoncode8955 3 роки тому

    please make a course for data structures and algorithms in python

  • @mananshah4031
    @mananshah4031 3 роки тому

    So if I have int x = 2, the statement int y = &x would store the give me a hex value?

  • @Anto-mi5pn
    @Anto-mi5pn 3 роки тому

    Backend code with c++. That'd be fun.

  • @NIKOLAS_MENY
    @NIKOLAS_MENY 3 роки тому

    when will you make the series with java as game develop

  • @mrgamer-lu1im
    @mrgamer-lu1im 3 роки тому

    pointers will be the next topic c++ is actually c but a superset

    • @OGBhyve
      @OGBhyve 3 роки тому

      I remember hearing this said a lot, but the two languages diverged. C++ is a superset of C89, but C99 and newer standards are not compatible with C++. That said, the most common compilers do support both languages.

  • @binaprajapati7709
    @binaprajapati7709 3 роки тому +1

    10th I guess

  • @not_urda
    @not_urda 3 роки тому

    3rd :) still early tho

  • @s.dh29
    @s.dh29 3 роки тому

    5th 😂