"I think I might do a video on [side topic]" Just gotta wait 10 more years
@mehmetcanturkes72284 жыл бұрын
I'm constantly amazed of how useful these series are. Thank you for creating these.
@GabeRundlett5 жыл бұрын
Keep up the C++ videos! It's awesome when you talk idiomatic c++ because it's really informational
@zraakuladann39465 жыл бұрын
Thanks for this video. What a councidence, lately ive been re-watching all your C++ playlist.
@dafdaf40525 жыл бұрын
Your channel is amazing and very informative. Have you ever thought about making a 2-3 hour video, where you complete a project and explain it step by step? I have been using lots of resources, but yours is truly inspiring. Keep up the good work!
@Mono-ip2fx5 жыл бұрын
Finally c++ series continues!
@aleksandarfranc10945 жыл бұрын
Yeaaah Cherno is BACK with C++ series. Thanks. Keep on going bro.
@notsalman5 жыл бұрын
Can you please do a video on C++20? Thanks. Also love your videos!
@supremedeity90035 жыл бұрын
is c++20 already here?
@kenappleman54445 жыл бұрын
Check out Jason Turner on KZbin he is a member of the c+-+ committee and does tons of c++20 videos
@climatechangedoesntbargain91405 жыл бұрын
also checkout cppcon, they have been presenting c++20 for years.
@kenappleman54445 жыл бұрын
@Peterolen no not 100% sure but he covers a boat load of c++ 20 features, it's good stuff
@notsalman5 жыл бұрын
Ken Appleman Awesome! I’ll check it out. Thanks
@broly49885 жыл бұрын
I'm so glad you updated this series! The microphone is taking a bit to get used to but cheers!
@justpaulinka5 жыл бұрын
So happy that you've finally starded making more videos about C++!
@fallingpizza115 жыл бұрын
My prof sucks and makes learning C++ boring and a chore. After every lecture I'll always watch your video on the topic and instantly get it. So thanks!
@vanjamijatovic63325 жыл бұрын
Just never stop making videos! Ur awesome
@jean-fredericfontaine2695 Жыл бұрын
The speed at which i was able to get back to c++ because of you is staggering. thank you brother.
@DavidRodriguez-mx1nw4 жыл бұрын
I'm studying c and c++ at 42 School and your videos are helping me out a lot. Thanks for all this content.
@1Dr490n Жыл бұрын
Kinda funny how people always speak about code optimization when talking about the fast-as-hell language C++ (like, how to decrease time by .00001µn), but writing reeaaally slow and often weird code when using python (optimal code: 3s, chosen code: 35s)
@aleksandarristoski27773 жыл бұрын
I just want you to know how much your work has helped me and you should be appreciated more. Great job!
@ThatOneBullet5 жыл бұрын
Best game dev/c++ channel!
@sirenti93845 жыл бұрын
could you do a video about lvalue and rvalue references in C++. It would be pretty helpful
@klarnorbert4 жыл бұрын
lvalue: values, that you can refer with a name(variable), like int a. Rvalues are which are not lvalues. int a = 5, 5 is rvalue. Rvalues only can appear at the right side of an assigment, you can't do this for example: 5 = int a;
@damnstupidoldidiot87764 жыл бұрын
@@klarnorbert An rvalue reference is an lvalue (or an xvalue, I forgot which).
@fruitgummy49354 жыл бұрын
I've been watching your videos for my cs projects and they are super super informative and straight-forward, thank you!
@zetadimensions5 жыл бұрын
Very well explained! I hope you make more C++ videos as they are very useful.
@kocho42425 жыл бұрын
dynamic_cast, when fails, doesn't always return nullptr. When we are working with references (not pointers) bad_cast exception is thrown instead.
@pooria_garrett30205 жыл бұрын
Why would we even use reference with it to cause an exception?
@shaondawsoums36445 жыл бұрын
Hey Cherno !! Thank you for all the work you put into these videos.. Can you do one on Exception Handling and how/where to use it.
@yellowcrescent4 жыл бұрын
Have always wondered how this worked-- have never heard of RTTI (for C++) before. A few months back I tried poking around UE4's Cast-related classes to see how they handled dynamic casting, but they use a ton of templates and their own type annotation system, which made it difficult to parse. Thanks!
@0x9075 жыл бұрын
HOLY SHITTTTTT THE LEGEND IS BACK WITH THE GOOD SHIT
@quadadulahma42975 жыл бұрын
Can you do a video on c++ variadic template functions? I really struggle on those.
@Narblo5 жыл бұрын
I think he did one of those. There is a video where we work we variadic template funcitions. Logging system in game engine series i think
@bamberghh16915 жыл бұрын
@@Narblo i still think that variadic templates need a separate video
@theRealSPACEDANCE5 жыл бұрын
@@bamberghh1691 It definitely needs its own video. Variadic templates are pretty rough at first, a lot of people had a hard time with understanding that part in the game engine series.
@alanmejia13305 жыл бұрын
Thank god a new video 🙏🏽
@avtem5 жыл бұрын
Thanks for making your videos, I appreciate them so much!
@adamshield50295 жыл бұрын
Great stuff! I never appreciated the value of dynamic cast before but it can actually be super handy. It's like a visitor in variants only for polymorphism.
@furkannarin28449 ай бұрын
So, I could create a project where every C style casting is correct and the program wont crash. interesting
@AnhNguyen-q8k4 ай бұрын
wait the like button actually lights up. like magic. it's my first time seeing such a thing
@KIPeR97eS5 жыл бұрын
2 days ago i returned to this series, and you upload a new episode after 8 months lol
@worlddj13645 жыл бұрын
Welcome back man.
@eleganteatinginjapan6595 жыл бұрын
Would really appreciate a video on static_cast, const_cast, reinterpret_cast and dynamic_cast and the differences between them
@ultimatesoup Жыл бұрын
Static: cast done at compile time, safe if you KNOW the type Const: add or remove const. Should never use this one. Const should never be removed and if you need to add const you can use std::as_const() instead. Dynamic: does a runtime check to make sure the cast is valid Reinterpret: completely changes the type, this is primarily used when interacting with old C APIs.
@ThibChap4 жыл бұрын
To just check the type, you can actually use the *typeid()* function, which I believe is faster. if (typeid(actuallyEnemy) == typeid(Player)) // ... It's roughly equivalent to typeof() and object.GetType() in C#. Great videos by the way!
@ultimatesoup Жыл бұрын
I would not use typeid....it typically doesn't work the way you'd expect because it gives you the EXACT mangled types so pointer, ref, const, volatile all come along for the ride
@cesarnunez88022 жыл бұрын
Your videos are saving my life!
@BosakMaw4 жыл бұрын
In 8:10 it's better to define a virtual destructor like you mentioned in previous video.
@danielphd50725 жыл бұрын
Thank you for this video about Dynamic Cast in C++ #cpp #cplusplus That was very informative
@firnekburg49905 жыл бұрын
Thank you so much ! Best explanation ever.
@MadpolygonDEV3 жыл бұрын
Incredible useful video for game programing
@h.hristov5 жыл бұрын
Love u man. Can you do more modern c++ videos please - STL specifically
@baaryl5 жыл бұрын
Finally we have new c++ video 😀
@UnWorld3 жыл бұрын
If you pause at any point, you can notice Cherno intensely gazing into your soul
@DDeathdealer0075 жыл бұрын
It'd be cool to have suggestions about alternative coding patterns in the case that you want to avoid the overhead/cost of dynamic casting. Great video, thanks!
@smarthumanism32212 жыл бұрын
Thank you for the teaching!!! Great lectures!
@zjfjack4 жыл бұрын
Actually, I think we can use if (auto p0 = dynamic_cast(actuallyEnemy))
@mladen7774 жыл бұрын
Does it throw an exception when encountering a dynamic cast with RTTI disabled, if in case of RTTI enabled, the dynamic cast is successful?
@MsJavaWolf5 жыл бұрын
You should do the other casts next, this video will be more educational in the context of all types of casts.
5 жыл бұрын
Thanks Cherno!
@aquavitale35515 жыл бұрын
Classic C++ series scenery and hairstyle!
@SimplySpiceIt5 жыл бұрын
Isn't that enough/ essential to provide a virtual destructor to the base class to achieve the polymorphism, rather than providing a virtual function(which may or may not have in a Base class)? In short, virtual ~Entity() = default; is essential than having a virtual member function in Entity at first place(IMHO).
@KishoreG23965 жыл бұрын
Yes, you should always provide a virtual destructor for polymorphic base classes. I recommend just making all destructors virtual (unless the class is marked final) whether or not they are in inheritance just so you don't have to deal with the problem if you ever decide to inherit from that class. Of course, a virtual destructor will automatically make that class polymorphic and thus generate a vtable but there really is close to zero overhead with modern compilers.
@vinniciusrosa82844 жыл бұрын
My way of learning is not that fast. I have to watch a lot of times to really understand that, but... I liked you video! Thank you.
@buddhasarchive83854 жыл бұрын
thanks. very clear to understand
@abhisheksa6635 Жыл бұрын
Nice explanation
@alexandre83503 жыл бұрын
Thanks
@MrTomro5 жыл бұрын
Amazing man, explained so well...
@YashPandey_the_emperor3 жыл бұрын
7:15 Imposter!
@mystmuffin360011 ай бұрын
Why does dynamic_cast require the base class to be polymorphic?
@bryanlozano89053 жыл бұрын
You are really good! Thanks!
@VasaMusic4385 жыл бұрын
Great !! A new c++ Video !! THANKSSSSS!!!!!
@ben9631473 жыл бұрын
Thank you, helped me a lot
@zoriiginalx75445 жыл бұрын
C++ series back :D
@MarcoGiordanoTD5 жыл бұрын
Isn't usually dynamic casting cosindered a code smell? Not for anything dynamic cast is doing, but mostly because you are breaking your polymorphism abstraction, which mostl likely means polymorphism might not be the right approach for the task? Of course as all things in programming is not an hard rule there are of course valid use cases.
@climatechangedoesntbargain91405 жыл бұрын
consider a client knowing the type and passing it a function which operates on the super class. The function returns a object of the same type -> you know what the type is.
@MarcoGiordanoTD5 жыл бұрын
@@climatechangedoesntbargain9140 the thing is why do you need to know the type in the first place? if you do probably polymorphism might not be what you need? Sure you know the type you know is going to be safe and is going to succeed to cast. Can't what you are trying to do be achieved with a virtual call? If not then why using polymorphism? Possible other design can be envisioned.
@climatechangedoesntbargain91405 жыл бұрын
@@MarcoGiordanoTD e.g. the server needs me to implement a certain interface - but I still want to use the other methods (not in interface) after the server has processed my object. Because the server does not (need) to know the specific type, it also does not return a object of the specific type.
@climatechangedoesntbargain91405 жыл бұрын
@@MarcoGiordanoTD what would be an alternative? given that runtime polymorphism is needed?
@MarcoGiordanoTD5 жыл бұрын
@@climatechangedoesntbargain9140 There are different methods than polymorphism, a more c like method might be to use opaque handles passed to a manager which keeps bookkeping of POD structs. You convert to the right struct and use functions on it. This avoids the whole vtable/inheritance going up and down the inheritance. This might not be ideal of course, as might not be polymorphism. Really depends on the use case, what I am trying to say is, lets just not start sprinkle dynamic cast everywhere but really consider what we are doing, dynamic cast usually is a "heavy duty" weapon :D
@caesarzheng38154 жыл бұрын
Beautiful..
@TheZenytram3 жыл бұрын
for what it would need to be used ?
@DipsAndPushups Жыл бұрын
Why doesn't dynamic cast return an optional?
@seditt51465 жыл бұрын
I was just asking this question last night on OLC discord asking about if I should or shouldn't do this in order to gather information about Collider* type passed into a resolver method. I still am not sure if I should go this route or not.
@comfypillow21315 жыл бұрын
thanks for doing this.
@michael541 Жыл бұрын
As I understand Dynamic cast is the similar as Cast in Blueprint. Am I wrong??
@vaggo9611 Жыл бұрын
🎯 Key Takeaways for quick navigation: 00:00 📚 Precompiled headers improve compilation speed significantly. 03:55 📦 Precompiled headers store commonly used header files in a binary format for faster compilation. 05:18 ❌ Avoid including frequently changing files in precompiled headers to prevent slow rebuilds. 06:44 🧩 Precompiled headers are useful for external dependencies and standard libraries. 09:03 📝 Including dependencies directly in source files can improve code modularity and readability. 11:46 💡 Precompiled headers are most beneficial for code you don't frequently modify. 14:13 🖥️ In Visual Studio, create a CPP file for the precompiled header and set it to create precompiled headers in properties. 17:44 ⏱️ Using precompiled headers reduces build time significantly, especially for larger projects. 18:52 🐧 In GCC, compile the precompiled header to a binary format and include it for faster compilation. 20:27 🤖 Precompiled headers should be used in nearly every software project for faster builds. Made with HARPA AI
@sergeykolesnik11715 жыл бұрын
Like in the previous videos, here you have mentioned the overhead when using dynamic_cast (contrary to static_cast). So, my question is: what would be the difference in perfomances if instead of dynamic_cast checking, you first validate the ID (interface ID, get it via overloaded pure virtual function like "virtual size_t IID() const = 0") and then use static_cast?
@master1382 жыл бұрын
Is dynamic_cast function a part of iostream?
@0xlyptox3965 жыл бұрын
Hey, which Theme is that? It's really awesome :D
@cole-nyc5 жыл бұрын
It's Visual Assist's default theme, and it is awesome!
@mithunk24915 жыл бұрын
Informative video. Can you please make a video on Exception handling and how to use them in programs?
@b0570nk45 жыл бұрын
So what happens when you disable RTTI and use static_cast() on a mismatching instance?
@BOTHLine4 жыл бұрын
How do virtual functions work if RTTI are turned off? how does Entity* e = Player(); know that it has to perform the overridden function in Player?
@BOTHLine4 жыл бұрын
@Peterolen so the object Entity* e = Player(); contains a pointer to a Player-specific table with all the overwritten functions? Wouldn't be there some information about the class itself, so you can find out it still is a Player object? It's hard for me to grasp why virtual function overloading works but dynamic cast wouldn't
@nickvirus94635 жыл бұрын
keep going!
@darkferiousity2 жыл бұрын
Interesting I am just wondering you had to add in a virtual function to let it know it is a polymorphic type, but is there a way of just stating after class that it is polymorphic? Thank you Cherno love watching your videos dude.
@cmdlp41785 жыл бұрын
Every virtual base class should contain at least a virtual destructor! Like 》~Entity()《. You need this function, to enable destruction of the subclass when destroyed from the baseclass.
@SomeDeath19905 жыл бұрын
thanks papaiwannou
@Lastrevio5 жыл бұрын
2:29
@semicolon46715 жыл бұрын
I can smell an entity component system 😊
@climatechangedoesntbargain91405 жыл бұрын
what?
@pooria_garrett30205 жыл бұрын
@@climatechangedoesntbargain9140 ECS a system used in game engines
@paulcook7485 жыл бұрын
I quite like your style of teaching. All very good. I don't have time to watch the entire thing right now but I do hope at some point you strongly make the point that in 99% of cases, if you are finding yourself using dynamic_cast then it is because your design is flawed. I admit I cheat with this for work when I'm in a hurry but dynamic_cast has almost no legitimate uses in a well designed codebase. Google Liskov's Substitution Principle if you wish a more thorough understanding of why.
@1Infinitive15 жыл бұрын
yeah, if ur using dynamic cast reconsider ur design choices
@yodaddy054 жыл бұрын
how would this work with smart pointers, thank you!
@yodaddy054 жыл бұрын
@Peterolen thank u so much!
@bestganesh3 жыл бұрын
I really got a good insight after watching this video twice...
@Red-di7zb5 жыл бұрын
Almost first, but no and this is at 2:35 am just to see a such amazing video.
@hypermeero47823 жыл бұрын
why are you amazing?
@AntiWanted3 жыл бұрын
Nice
@kajonpongpoopamonkaipob61535 жыл бұрын
Teach for design patturns please
@mrhidetf25 жыл бұрын
First second is the begging of ricardoflick
@timelesstrance37205 жыл бұрын
More on principle of design
@doomstothfilms2 жыл бұрын
I really hate that you can explain more in 10 minutes than a professor can in 2 hours.
@kacperozieblowski38095 жыл бұрын
musics good mhheen
@orocimarosay14475 жыл бұрын
well I guess c style cast in this context is undefined behaviour so it won't probably work in a context where entity and player look the same
@nickvirus94635 жыл бұрын
gsl next?
@shivaprasad7615 жыл бұрын
Yay c++
@MsJavaWolf5 жыл бұрын
Really happy that you are doing C++ videos again, I really like your videos but I am simply not very interested in game engines. One thing that could have been added to the video though would have been casting of references.
@nielsvs22035 жыл бұрын
MsJavaWolf personally I'm not a fan of casting references. While yes it's possible, it easily breaks. Take dynamic_cast for example, when this fails on a pointer, it will return null which you can easily check for and handle, but when it fails on a reference it will throw a std::bad_cast which is slightly more hassle to handle. Let me know your thoughts
@MsJavaWolf5 жыл бұрын
@@nielsvs2203 I don't really use dynamic_cast that often in general, but when I do yes, I use pointers more often.
@rcookie51285 жыл бұрын
*Appreciation comment*
@ultimatesoup Жыл бұрын
Be warned people watching this, if you find yourself using dynamic cast a lot, there is probably something wrong with your design. It has its uses, but legitimate situations for it are few and far between. There is also a slight performance hit for it because the check is done during runtime