Stop using these wrong.

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

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

  • @demikr8115
    @demikr8115 Год назад +29

    I’d definitely be interested in a video on what every version of C++ adds fundamentally if that makes sense? Like C++11, C++17, etc. specifics

    • @nathanbaggs
      @nathanbaggs  Год назад +17

      That’s actually on my idea list!

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

      @@nathanbaggs as a lapsed C++ programmer (stopped in 2013 and didn't fully learn C++11), I'd love to watch that video, I sometimes think of updating my C++ knowledge but not sure how to get started, it's overwhelming!

  • @suncrafterspielt9479
    @suncrafterspielt9479 Год назад +5

    Your videos are insanely useful. Usually content on youtube only scratches the surface in my experience

  • @damouze
    @damouze 9 месяцев назад +4

    While my main programming language of choice is plain old C, sometimes I do de(vo)lve into C++. I never understood the benefit of references compared to pointers (and I still don't, but that's not on you), but then again I maybe old-fashioned. I _want_ my objects to be nullable because that's the main way I signal to the caller that something went awry.
    Maybe I am a poor old sod who refuses to know any better ;-)
    I found your video interesting and it did clear up a couple of things. Even in my university days when I first learned C++, references were an obscure abstract topic that neither the professor nor my fellow-students (who were way more proficient with the language than I was) were willing to discuss. The same applied to templates. So I left them alone and instead continued to code in C and assembly.

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

    Just discovering this channel. You're pretty good at explaining C++ concepts! (no pun intended)
    I think you could do a video where you take some code (create_enitity for example) and "work up" to the final implementation. Like starting with the basic idea, and then changing the pointer to unique, explain the move semantics, etc.

  • @NeuwDk
    @NeuwDk Год назад +1

    I sometimes use std::optional instead of pointers when I need the equivalent of a nullable pointer. I don't know if it's a good idea, but somehow I tell myself that the type-system is holding my hand more when doing this, compared to a raw pointer.

  • @florian3421
    @florian3421 Год назад +5

    Very cool video! I'm currently looking a lot into how all the low level stuff works under the hood because its very interesting to me but find it quite hard to find good learning resources about some of it and your channel has helped me a lot. Would be really awesome if you could make a video about windows PE executables where you explain how they are structured and go through every byte of a very simple and small executable which e.g. just returns exit code 0 or some. Thanks!

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

      Glad you’re finding it useful, thanks for the idea!

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

    Interestingly, Java references are much more similar to C++ references, just wrapped in a dereferencing syntactic sugar hiding the pointer underneath.

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

    Copying a passing value, That's an error, you can address its value directly, in a Data Segment

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

    Just use a reference to a pointer.
    Easy peazy lemon cheesy

  • @alexxv.1519
    @alexxv.1519 10 месяцев назад

    The biggest offender is the ampersand and ptr on the side of the variable name

  • @svenlamberti
    @svenlamberti 3 месяца назад

    Shouldn't the body of the cmp_ptr(int* a, int* b) be return *a == *b; ?

    • @nathanbaggs
      @nathanbaggs  3 месяца назад

      The point (excuse the pun) is that directly comparing pointers compares whether the addresses are the same, whereas with references the value of the two objects are compared

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

    Please never stop thx

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

    I mean, ideally what you would do is make a wrapper in class for unique pointer that statically asserts that it's not null at construction time...