This is the best explanation of this topic I've seen so far.
@JGunlimited5 жыл бұрын
Perfect! Was stumbling on this topic, great to have an in-depth look.
@JohnDlugosz5 жыл бұрын
I was expecting something for more advanced programmers -- all the newer stuff about prvalue, xvalue, etc. and guaranteed copy elision. I think his material predates C++11, and he added some annotations like "now use nullptr" in a _comment_ where the slide has NULL. In (literally, the last 5 minutes (56:40)) he has an appendix to his legacy lesson, saying "C++11 changes things." and speeds through slides on lvalue references and the diagram of all the --value categories, but that appears at 59:23 and he spends a full 90 seconds on it.
@jvsnyc3 жыл бұрын
I don't know if you worked it all out since then, or just kind of forgot about it for a while. If the latter, I think this talk is fantastic: kzbin.info/www/bejne/oZ6WhqWlnMSqsM0 It's his only talk that I've seen on KZbin, but is terrific. Dan Saks works in the embedded world, and bounces back and forth between C and C++ a lot. There are other tells in the presentation. Who would ever use a non-Class enum in C++ but someone who also uses C almost every day? I think he would have talked some more about the modern twists and turns if his audience didn't keep asking questions, we lost a good five minutes of the end of the talk here. The talk I linked to is great, if you search, there is an alternate version of it with a slightly different scope of coverage.
@jvsnyc3 жыл бұрын
Also, from the same year, his son (I think) did this lecture, which while not quite the tour-de-force that the other one I linked to was, was also great and went into a few things a little more deeply maybe: kzbin.info/www/bejne/joSVe5eahdZqfbM
@yuwuxiong11654 жыл бұрын
good intro. i guess one of the other reasons behind the introduction of "reference" is because we want to let compiler to watch out for us not to miss use pointers when it's initialized once and never change.
@bonbonpony4 жыл бұрын
Nope, the real reason was what he talked about somewhere around 41:21 - operator overloading. Everything else might be considered a bonus. But without introducing references, overloaded operators couldn't work the same way as the built-in operators work. Long story short, if you want operator overloading to work as expected, you gotta introduce references.
@VishalSharma-ys9wt5 жыл бұрын
Really nice introduction!
@tijshoeijmakers35144 жыл бұрын
Great talk, but very annoying crowd...
@0x656e4 жыл бұрын
Such an amazing talk.
@agnesakne4409 Жыл бұрын
this man is good
@abdelrhmanahmed13784 жыл бұрын
int x = 6; int z = 10; int& p =x; p = 100; cout
@bonbonpony4 жыл бұрын
First tell us why do you expect `z` to contain 200? You never change `z` after you initialized it to 10. After you strip all that fuss you put around it, the `z` part of your program boils down to: int z = 10; cout
@ryanpxl4 жыл бұрын
When you create a reference you bind it at it's initialisation. So from the beginning p is an alias to x. Where ever you see 'p', you can harmlessly replace it with 'x'. So the statement "p=z" is actually "x=z", which is valid. You've changed the value of 'x' not 'z'. If you print out the value of 'x' you should get 10. I think that's how it works.
@MIKE6789MW3 күн бұрын
foolish to answer the dumb questions from the audience