C++ Casts

preview_player
Показать описание
Discussion of C++ casting operators.
Рекомендации по теме
Комментарии
Автор

Clean as a crystal, fluid and clean explanation, Lovin' it

rajeshful
Автор

Great Job! I also have a video on my channel that talks about casting, but I like your live-demo style of teaching. It's pretty neat.

BoQianTheProgrammer
Автор

You ability and method explain the concepts is commendable. Awaiting for more videos :)

yesiajay
Автор

Nice job, but I'm a little perplexed on the const_cast<> thing. Why would the compiler error you on trying to accept a const Rational object just because the member function(s) wasn't marked as const? Why would the compiler care? I mean, aren't you being MORE restrictive with the Rational object in your code (print function) than the class author allows?

If you think about it, unless I am not understanding this correctly, the compiler is basically telling you that you can't be as "safe" with your Rational parameter as you'd like to be. Just because the class author seemingly didn't care enough to make their getDouble() function constant, means that you now can't make YOUR function take a constant reference to a Rational object? So I'm slightly unclear about that part of the video.

I understand that you can use const_cast<> to get back your constant safety net, but I have to wonder...why should you have to go through that step, just because a class author didn't make their class const-correct?

Maybe I'm making it more complicated than it needs to be, but what am I missing here?

bluehornet
Автор

Great videos. I hope you keep making more c++ videos. If you're looking for ideas. C++ with opengl or better yet with Vulkan

ChristopherJones