Code for yourself
Code for yourself
  • 47
  • 120 834
The C++ Lambdas
Lambdas are just a thing without which it is impossible to imagine the modern C++ of today. Here we talk about what they are, what we can use them for and touch a bit upon how they function under the hood.
🙏 *Support what I do*
Please consider using the *super thanks* ❤️ !
Other options to show your support:
⏺ Join my channel and access the perks: th-cam.com/channels/Rm39hwBxsX-8yj2xs3OJjQ.htmljoin
⏺ Support me on Patreon: patreon.com/code_for_yourself
⏺ Sponsor me on GitHub: github.com/sponsors/niosus
📚 Link to the script to this video on GitHub: github.com/cpp-for-yourself/supplementary-materials/blob/main/lectures/lambdas.md
🔗 *Links*
⏺ Lambdas: en.cppreference.com/w/cpp/language/lambda
⏺ std::sort: en.cppreference.com/w/cpp/algorithm/sort
⏺ Function to pointer conversion: en.cppreference.com/w/cpp/language/implicit_conversion#Function-to-pointer_conversion
⏺ Function objects: en.cppreference.com/w/cpp/utility/functional
⏺ std::find_if: en.cppreference.com/w/cpp/algorithm/find#Version_3
⏺ std::for_each: en.cppreference.com/w/cpp/algorithm/for_each
⏺ std::transform: en.cppreference.com/w/cpp/algorithm/transform
#cplusplus #programming #coding #tutorial
มุมมอง: 1 376

วีดีโอ

Never free memory yourself! Do this instead (in modern C++)
มุมมอง 2.8Kหลายเดือนก่อน
Arguably this is the most important video to understand how memory is allocated in C . Even more, we cover not just how it can be allocated manually but how it allows C to be so fast as well as how to do it safely in modern C . *We cover* ⏺ What memory management is ⏺ Why garbage collection is not the way to go ⏺ What is stack and how it enables quick allocations and de-allocations of small var...
INHERITANCE in C++ | most of the things you need to know for OOP and beyond 🚀
มุมมอง 1.1K2 หลายเดือนก่อน
In this video we cover most of the things that one might encounter when working with inheritance in modern C . We go over a broad list of topics, starting from why we care about inheritance (spoiler alert: to enable dynamic polymorphism) and digging down into the rabbit hole of how it mixes with implementation inheritance (not that well), what is object slicing and what we need to keep in mind ...
Separate declaration and definition for C++ templates? Yes please (sometimes)
มุมมอง 1.9K3 หลายเดือนก่อน
It seems that the topic of compiling templated code in C into libraries is one of the typical contention topics for lots of people when they use templates in their code. In this video we look into why this topic can be perceived as such a complex one as well as how we can actually achieve what we want. 📚 As always, you can find the full script to this video as well as all the code shown on the ...
Why use forwarding references and how they are different from rvalue references in C++
มุมมอง 2.2K4 หลายเดือนก่อน
Since C 11 was released there has always been quite some interest in forwarding references among people practicing C . On one hand, it is a very powerful mechanism, on the other, it requires quite some knowledge about how templates work so it is met with a lot of fear among people learning C . In this video, we cover everything there is to know about forwarding references, why we might want to ...
How to use CLASS TEMPLATES, type traits, partial and full class template specialization
มุมมอง 1.1K5 หลายเดือนก่อน
Class templates with the ability to partially and fully specialize them are arguably what makes C so powerful! We cover most of what one needs to know about what class templates are, how to specialize them fully or partially as well as how it all plays its role if we want to implement type traits. Before you watch this video I recommend you to watch these videos if you haven't already: - *why* ...
How to use FUNCTION TEMPLATES - a comprehensive guide for modern C++
มุมมอง 2.5K7 หลายเดือนก่อน
Writing function templates is part of the core skills we can use as a C programmer! Today, we cover close to everything there is to know about this topic skipping only very few cases that we leave for the future. Before you watch this video I recommend you to watch these videos if you haven't already: - *why* use templates: th-cam.com/video/1Mrt1NM3KnI/w-d-xo.html - *what* templates do under th...
Templates under the hood
มุมมอง 1.3K8 หลายเดือนก่อน
The second video out of a number of videos about templates. Here we focus on *what* templates do under the hood. Or, more precisely what a compiler does when it sees templated code. If you want to know *why* use templates in the first place, see: th-cam.com/video/1Mrt1NM3KnI/w-d-xo.html 📚 As always, the script to the video lives here: github.com/cpp-for-yourself/supplementary-materials/blob/mai...
Why use templates in modern C++
มุมมอง 2.1K8 หลายเดือนก่อน
The first video out of a number of videos about templates. Here we focus on *why* anybody would want to use templates in the first place, leaving the details to what templates do and how to properly use them in C to the future videos. If you want to know *what* templates do under the hood, see this video: th-cam.com/video/NKvEbPVllRE/w-d-xo.html 📚 As always, the script to the video lives here: ...
Use static in classes (when needed) in modern C++
มุมมอง 1.6K10 หลายเดือนก่อน
Everything that you wanted to know about static (when it is used *inside* of classes) but were afraid to ask. For when (not) to use static *outside* of classes, see th-cam.com/video/7cpPQunjv4s/w-d-xo.html 📚 As always, the script to the video lives here: github.com/cpp-for-yourself/supplementary-materials/blob/main/lectures/static_in_classes.md 00:00 - Intro 01:26 - Static class methods 04:54 -...
Don't use static (outside of classes) in modern C++
มุมมอง 5K11 หลายเดือนก่อน
Everything that you wanted to know about static (when it is used outside of classes) but were afraid to ask. The video on using static *in* classes can be found here: th-cam.com/video/ggNCjDPShrA/w-d-xo.html UPD: Had to re-record and re-upload due to some issues with the previous attempt at this video. 📚 As always, the script to the video lives here: github.com/cpp-for-yourself/supplementary-ma...
Const correctness in C++
มุมมอง 3.3Kปีที่แล้ว
Here we look at const correctness as one of the cornerstone parts of C . We already know how to write our functions and classes and have access to all use cases where we can and want to use const keyword. So we cover most of these use cases here. 📚 As always, the script to the video lives here: github.com/cpp-for-yourself/supplementary-materials/blob/main/lectures/const_correctness.md
Project: Pixelate Images in Terminal 😎
มุมมอง 1.3Kปีที่แล้ว
We've learnt a lot until now. We know how to write classes, how to implement proper move semantics for them as well as how to create full projects with CMake. Now it is time to put it all to a test by implementing a project that allows us to load an image from disk, pixelate it and show it to the user in the terminal. 📚 As always, the script to the project description lives here: github.com/cpp...
Headers and libraries, but with classes
มุมมอง 1.6Kปีที่แล้ว
We know how to write libraries when using just functions. Is it any different when we use classes? We'll figure out in this video! Turns out the situation is nearly the same as when not using classes with just a couple minor differences. 📚 As always, the script to the video lives here: github.com/cpp-for-yourself/supplementary-materials/blob/main/lectures/headers_with_classes.md The chatbot use...
Safely copying, moving, and destroying objects in Modern C++ with the rule of "all or nothing"
มุมมอง 2.4Kปีที่แล้ว
Which constructors does a C class need? Which does it generates on its own? What about various assignment operators? And a destructor? How not to shoot ones leg off and navigate these waters effortlessly? This and more we cover in this video that tells us a simple rule to follow when implementing classes in Modern C , the rule of "all or nothing". We dive into the reasons for its existence and ...
Re-inventing move semantics in modern C++ in 13 minutes
มุมมอง 6Kปีที่แล้ว
Re-inventing move semantics in modern C in 13 minutes
C++ object lifecycle 101: the essentials
มุมมอง 1.1Kปีที่แล้ว
C object lifecycle 101: the essentials
Mastering C++ pointers: the pros and cons of (raw) pointers | pointer usage with const
มุมมอง 1.7Kปีที่แล้ว
Mastering C pointers: the pros and cons of (raw) pointers | pointer usage with const
C++ classes: the basics
มุมมอง 1.4Kปีที่แล้ว
C classes: the basics
Can you write a proper CMake library? | homework 📚
มุมมอง 1.7Kปีที่แล้ว
Can you write a proper CMake library? | homework 📚
1000 subscribers AMA answers
มุมมอง 360ปีที่แล้ว
1000 subscribers AMA answers
Do you even test? (your code with CMake)
มุมมอง 24Kปีที่แล้ว
Do you even test? (your code with CMake)
1000 subscribers AMA
มุมมอง 273ปีที่แล้ว
1000 subscribers AMA
Enumerating options in C++ using enums
มุมมอง 884ปีที่แล้ว
Enumerating options in C using enums
CMake - the essential package
มุมมอง 11Kปีที่แล้ว
CMake - the essential package
🏗️ Build your libraries easier using build systems
มุมมอง 1.6Kปีที่แล้ว
🏗️ Build your libraries easier using build systems
C++ libraries and what inline has to do with them
มุมมอง 3.7K2 ปีที่แล้ว
C libraries and what inline has to do with them
Functions in modern C++ and some related best practices 👌
มุมมอง 1.4K2 ปีที่แล้ว
Functions in modern C and some related best practices 👌
Common compilation flags and debugging a C++ program
มุมมอง 1.7K2 ปีที่แล้ว
Common compilation flags and debugging a C program
Homework: the guessing game
มุมมอง 3652 ปีที่แล้ว
Homework: the guessing game

ความคิดเห็น

  • @Maximus98245
    @Maximus98245 วันที่ผ่านมา

    Great content! Yes to Concepts!! and multi-threading..and coroutines too..ok, I am pushing it I know...

    • @CodeForYourself
      @CodeForYourself วันที่ผ่านมา

      @@Maximus98245 coroutines probably won’t happen. Everything else might 😉

    • @zamf
      @zamf วันที่ผ่านมา

      @@CodeForYourself Yeah, coroutines are for library developers. Not something that can be explained in a 10-20 minute youtube video.

  • @segfault4568
    @segfault4568 วันที่ผ่านมา

    Great video, would be nice to cover function pointers and std::functions also the differences and use cases.

    • @CodeForYourself
      @CodeForYourself วันที่ผ่านมา

      @@segfault4568 yes, absolutely! I hope to be able to get to it at some point. But as I mentioned before to properly talk about std::function I would kinda need to chat about type erasure and I’m not sure if I should or if I can do it in a simple enough way. Thinking about it anyway.

  •  วันที่ผ่านมา

    I'd appreciate a lecture on concepts! Bare templates are a bit confusing and their error messages are confusing. I guess concepts help with understanding what the types are for in the template.

    • @CodeForYourself
      @CodeForYourself วันที่ผ่านมา

      Yes, exactly. Let’s see if I get to record a video about this.

  • @zamf
    @zamf วันที่ผ่านมา

    Lambdas are my favourite feature of C++. They enable so much expressiveness and because of them some consider C++ to be a functional programming language (or at least a programming language that can be written in a functional style). You should also do a video on std::function, which combined with lambdas makes for some really powerful coding patterns. Also, in C++23 they introduced std::move_only_function, which is a more optimized version of std::function for captured objects that are not copyable. And in C++26 they're introducing std::function_ref, which is a light-weight version of std::function. As for lambdas, it should be noted that they can be templated as well. And one more important thing about lambdas is that they return their result by value by default, meaning that if you want a lambda that returns a reference you need to specify its return type as "auto&" or "decltype(auto)" or something similar to this.

    • @CodeForYourself
      @CodeForYourself วันที่ผ่านมา

      @@zamf thanks! All good points! I’m still mostly targeting C++17 here just to make sure I have something finished before moving on to new standards. So no goodies that you described. Also, I’m not trying to completely copy cppreference here. The aim is to give people enough knowledge to be able to dig further. Hope this explains a bit better some choices I make in these videos.

    • @zamf
      @zamf วันที่ผ่านมา

      ​@@CodeForYourself I agree. I just think that std::function is a good candidate for a future video as a follow up to this one.

    • @CodeForYourself
      @CodeForYourself วันที่ผ่านมา

      @@zamf definitely. That video I really want to record at some point but a proper deep dive into how it works requires type erasure and I’m not sure how long it will take me to distill it into a manageable explanation 😅

    • @Maximus98245
      @Maximus98245 วันที่ผ่านมา

      The biggest issue with std::function is that it doesn't respect the const-ness (other than a smaller issue of it might need to allocate and takes up 32 bytes as opposed to 8 for function pointer) struct Functor { int x = 0; void operator()() { ++x; } }; const Functor func; //func(); // good, this will not compile const std::function<void()> stdfunc = Functor{}; stdfunc(); // compiles, I can mutate const std::println("stdfunc.target<Functor>()->x == {}", stdfunc.target<Functor>()->x);

    • @zamf
      @zamf วันที่ผ่านมา

      @@Maximus98245 That is weird, I agree. But it's a similar behaviour to const pointers and even to const std::reference_wrapper. So not that unexpected. At least it modifies a local copy of the data, so nothing else in the program is modified.

  • @viktordiadkov8768
    @viktordiadkov8768 วันที่ผ่านมา

    Amazing! comment to promote

    • @CodeForYourself
      @CodeForYourself วันที่ผ่านมา

      @@viktordiadkov8768 thanks! Highly appreciate it! 🙌

  • @Maximus98245
    @Maximus98245 3 วันที่ผ่านมา

    Great video! I keep coming back to this when ever I need a refresher on maps. One thing I wish you had mentioned here is, the iterator invalidation/stable addressing. std::map and unordered_map guarantee that any references to the keys/values are valid after insertions and deletions but some 3rd party faster implementations (like Abseil) do not and I found this out the hard way. Overall awesome material!

    • @CodeForYourself
      @CodeForYourself 3 วันที่ผ่านมา

      @@Maximus98245 thanks! 🙏 You’re making a good point. I felt like this was more introductory video so skipped that. I probably should eventually talk about it but don’t know when I’ll manage. 😅

  • @ozimandias1858
    @ozimandias1858 3 วันที่ผ่านมา

    Why is the method where we download GTest sources, save them to our system, build them, and then include them in our project using something like this (look down) now deprecated? enable_testing() find_package(GTest REQUIRED) include(GoogleTest) add_executable(tests tests.cpp ) target_link_libraries(tests GTest::gmock GTest::gtest ) gtest_discover_tests(tests)

    • @CodeForYourself
      @CodeForYourself 3 วันที่ผ่านมา

      @@ozimandias1858 well, deprecated is a strong word for it, you’re right. But it is discouraged. The suggested way is to “live at head” as mentioned in their readme: github.com/google/googletest#live-at-head

    • @CodeForYourself
      @CodeForYourself 3 วันที่ผ่านมา

      @@ozimandias1858 they also only provide the fetch_content example in their docs: google.github.io/googletest/quickstart-cmake.html

  • @gandhisFlipFlops
    @gandhisFlipFlops 4 วันที่ผ่านมา

    Is there a video on arrays? I search the word array and couldn't see anything on the playlist.

    • @CodeForYourself
      @CodeForYourself 3 วันที่ผ่านมา

      I guess the closest video to this would be this one on various STL containers: STL sequence containers (and friends) in modern C++ th-cam.com/video/dwkSVkGsvFk/w-d-xo.html

  • @gandhisFlipFlops
    @gandhisFlipFlops 5 วันที่ผ่านมา

    I think it would be way better if there was less face cam and more visuals related to the topic being talked about or code screen.

    • @CodeForYourself
      @CodeForYourself 5 วันที่ผ่านมา

      I largely agree. Towards later videos I converged to a very different format.

  • @Ekalai
    @Ekalai 9 วันที่ผ่านมา

    Awesome, You are rock man!!!... 🌹💖

  • @01MeuCanal
    @01MeuCanal 24 วันที่ผ่านมา

    Hi there! C++ templates can produce the worst error messages. Could make some videos about that? How to understand template error messages and debug templated code?

    • @CodeForYourself
      @CodeForYourself 24 วันที่ผ่านมา

      Oh yes! That is a great idea! I wanted to make a video like that for a long time. It will take me a bit of time though as I have just started a new job and all my time is spent there for now. But I’ll get to it one of these days.

  • @antonfernando8409
    @antonfernando8409 25 วันที่ผ่านมา

    Really great, glad to discover your cmake videos. As I am looking into strange link errors with static libs made with C, used in c++ apps, but cmake somehow linking wrong things. That lib property thing could be something understand more. Thanks.

    • @CodeForYourself
      @CodeForYourself 22 วันที่ผ่านมา

      Glad I was of some help. One recommendation to debug this type of linking errors is to start small and try to get to the smallest reproducible example first. Good luck!

  • @alperzobu9534
    @alperzobu9534 26 วันที่ผ่านมา

    One of the best I have ever listened!

    • @CodeForYourself
      @CodeForYourself 26 วันที่ผ่านมา

      @@alperzobu9534 thanks for such a high praise!

  • @ozimandias1858
    @ozimandias1858 หลายเดือนก่อน

    Буду откровенен, пересматривал 4 раза, и все рано не во всем разобрался. Так и не понял, для чего нам сохранять переменные с каким-то текстом. Однако, отличное видео - нужно просто приложить немного усилий. Мне, кажется, ролика хватит, чтобы понимать 90% cmake файлов. Все четко, и без воды

    • @CodeForYourself
      @CodeForYourself 29 วันที่ผ่านมา

      Дякую за хороші відгуки! Стосовно змінних, загалом всі змінні в cmake це просто текст. І більшість цього тексту зберігається в кеші який потрібен для того щоб зберігати конфігурацію між запусками. А все інше про за я розказую то наслідки цього.

    • @ozimandias1858
      @ozimandias1858 28 วันที่ผ่านมา

      @@CodeForYourself Да, только момент с кешем не уловил. Все остальное кристально. Особенно понравилась презентация на гитхабе. Я вот раньше просто смотрел, ничего не повторяя. Сейчас Вы сказали "не тупить" и выполнить все самостоятельно. Начал это практиковать. Времени намного больше занимает, но после ощущение будто сам все сделал. А если вопросы есть, гпт использую. Еще раз спасибо :-). Подписка, лайк

    • @CodeForYourself
      @CodeForYourself 28 วันที่ผ่านมา

      @ozimandias1858 будьте обережні з гпт, адже він хронічно бреше. Будь які конкретні запитання можна також задавати тут або на гітхабі. Я відповідаю повільніше за гпт, але сподіваюсь що менше брешу 😅

  • @Pedro-jj7gp
    @Pedro-jj7gp หลายเดือนก่อน

    Very nice video, thank you! What do you use for the code and diagram animations at the end?

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Thanks for the compliments! Whenever you see code animations I use motioncanvas.io The rest of the animations, including the last diagram animation here about shared pointers, I make by creating images with the Apple's Freeform, import them into Davinci Resolve where I edit my videos, and do the rest of the animations there.

  • @erkamkocaer2097
    @erkamkocaer2097 หลายเดือนก่อน

    why did you use virtual on Write functions for jpegio and pngio at the final example code?

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      That is it make sure that when we call these functions we look up the actual functions to be called in the vtable. In the end of the example we pass a reference to an *IoInterface* object. So try to make sure you understand exactly what will happen when we call *Write* on such an object reference. Does this help?

    • @erkamkocaer2097
      @erkamkocaer2097 หลายเดือนก่อน

      ​@@CodeForYourself I understand what you mean but in the video you used "void Write(const std::filesystem::path& path, const std::vector<Color>& data) const override { std::cout << "Writing PNG to path: " << path << std::endl; }" function but on github you used "virtual void Write(const std::filesystem::path& path, const std::vector<Color>& data) const override { std::cout << "Writing PNG to path: " << path << std::endl; }" function for both png and jpeg. I expected and understood first function but did not understand second one.

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@erkamkocaer2097 oh! Now I understand! Thanks for pointing it out! It's a bug I have on GitHub. We *can* have *virtual* and *override* for the same functions but generally we should just use *override* as the *virtual* is implied here. So basically what I'm trying to say is that *override* implies *virtual*. I'll remove *virtual* from my GitHub code as it was probably a copy-paste error on my side. Thanks again!

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@erkamkocaer2097 I've updated the code on GitHub to not have *virtual* in the last example. Thanks again for bringing it up!

    • @erkamkocaer2097
      @erkamkocaer2097 หลายเดือนก่อน

      @@CodeForYourself thank you for your attention. I like your cpp videos. They are really impressive.

  • @Sheeldzy
    @Sheeldzy หลายเดือนก่อน

    I’ve been watching your channel and following along from the start. This video just helped me tie a lot of concepts together. Many thanks, keep it coming!

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Thanks a lot! Happy to hear it was useful!

  • @PerriPaprikash
    @PerriPaprikash หลายเดือนก่อน

    why do a video? why not simple write a nicely written article that people can read at their own leisure, and one where you can correct the numerous issues raised on the cpp subedit

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      That is a valid question. The main reason is that some people prefer a video format and a video allows me to do both, have a markdown article and a video. You can find the markdown under the video. The downside is of course that errors are harder to fix.

  • @richardbennett4365
    @richardbennett4365 หลายเดือนก่อน

    Then, he changed it back again at 6:05. 😂😮😅😅😅

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@richardbennett4365 Same explanation as for the first change. The blank T-shirt is the original recording and the “save the earth” one is the follow-up 😅

  • @richardbennett4365
    @richardbennett4365 หลายเดือนก่อน

    Nice, and why did the presenter change shirts at 5:10???

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@richardbennett4365 simple. I recorded everything and then, when editing found that the story wouldn’t add up. So had to re-record and add a part. But the old tshirt was already in the laundry basket 😅

  • @segfault4568
    @segfault4568 หลายเดือนก่อน

    About the manual delete, I always get questions from friends about whether they should use delete on a raw pointer they got as a return value from a function inside some old C library, It is all super confusing for beginners. Usually Documentation have it mentioned as "non-owning". It's amazing to see how all over the place each library's cleanup methods are.

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@segfault4568 yes, my experience exactly. That mess is exactly the reason for all the smart pointers 😬

  • @leonardodosanjoschaves6204
    @leonardodosanjoschaves6204 หลายเดือนก่อน

    I am just about to develop a “tree container”. The video content is so useful as an overview, clear, straight and didactic. Thanks

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@leonardodosanjoschaves6204 awesome! Glad to hear it was useful and good luck!

  • @leonardodosanjoschaves6204
    @leonardodosanjoschaves6204 หลายเดือนก่อน

    I am enjoying so much this course playlist. Thanks!!!

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@leonardodosanjoschaves6204 happy to hear that! 🙏

  • @JoseRomagueraM
    @JoseRomagueraM หลายเดือนก่อน

    It's great that people got interested by memory management, but I fully disagree with the usage of smart pointers and garbage collectors as a reliable and performant way of managing memory. Those techniques assumes that every "object" has his own lifetime, witch is fundamentally false: When there's one, there's many. This affects performance because of memory fragmentation and loses capabilities. I highly recommend the talk of Ryan Fleury about Arena Allocators, it's mindblowing how simple and effective a linear allocator can be. I almost never think about memory management and have all the performance and reliability.

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Arena allocators definitely have their use! However, if we allocate a lot of objects we will quickly need to manage memory in complex ways. This lecture targets largely the default behavior for beginners. I believe that using the heap for allocations should be completely fine in most domains. Also, heap implementations benefit from years of optimization and as far as I know they basically use arena like allocations for small objects. That being said, if one really writes a safety critical application and cannot use heap memory at runtime then yeah, we’ll probably need to allocate stuff from an arena. Also, I don’t agree with putting garbage collection and smart pointers in the same row. They are very different mechanisms. Smart pointers are definitely reliable and in case of a unique pointer have nearly no overhead. So if one wants to allocate on a heap, smart pointers are definitely a way to go.

  • @advik-b
    @advik-b หลายเดือนก่อน

    This is quality content, your channel is underrated bro

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@advik-b thanks for your kind words! Spread the word then. Let’s fix it. 😅

  • @div0826
    @div0826 หลายเดือนก่อน

    love this explanation

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Glad you liked it! 🙏

  • @bibekjha8129
    @bibekjha8129 หลายเดือนก่อน

    loving these videos.

  • @segfault4568
    @segfault4568 หลายเดือนก่อน

    Very Nice lecture, all my years I have always been a Composition over Inheritance supporter as well I knew that private inheritance can get the job done but never bothered to see how; example at 9:59 cleared the syntax and semantics up perfectly. ☺

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Glad it was helpful! 🙏

  • @pragyandahal7357
    @pragyandahal7357 หลายเดือนก่อน

    Amazing content Igor, keep up the good work.

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Thanks! I’ll try my best 👌

  • @SanjeevKumar-nm7ps
    @SanjeevKumar-nm7ps หลายเดือนก่อน

    you always deliver a masterpiece related to C++. Thank you so much for sharing your knowledge :)

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@SanjeevKumar-nm7ps thanks so much for your kind words! You make me blush! ☺️ Glad that it is useful to you! 🙏

  • @glaubercini
    @glaubercini หลายเดือนก่อน

    Great video, however I couldn't figure it out how you change your T-Shirt that fast 😄.

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Oh, that’s very easy. You just mess up in the script, spend a week editing, then see that it’s wrong and that you have to re-record parts. 😅

  • @jojify
    @jojify หลายเดือนก่อน

    Great. Do you have any udemy course in detail for c++. I would like to purchase it

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Not yet, but maybe some day once I finish a full course here.

  • @politejellydragon8990
    @politejellydragon8990 หลายเดือนก่อน

    Nah man, RAII is there for a reason. There is no free lunch. It's an indirection that in many cases isn't necessary. Writing a quick free with a null check into a destructor is not hard. Smart pointers are great for some things, but a shared pointer is inefficient and a unique pointer is kind of obsolete in many cases. I think nuance would make this a bit better. They should not be your default move. You should always evaluate your options.

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Could you elaborate a bit on how unique_prt is obsolete? This is the first time I hear about it.

    • @segfault4568
      @segfault4568 หลายเดือนก่อน

      How is Unique pointer obsolete? it executes the same instructions as Raw pointer, same size as well, Scott Myers even recommended them to be used in tight cycles. Shared pointer though not to be confused with Auto GC is still a deterministic destructor so plenty useful, the only inefficient thing I can recall about Shared pointer is that it is twice the size because of control block pointer.

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@segfault4568 I have a similar view (thus my original question to the OP). As for the shared pointer the reference count is atomic if I remember correctly, which requires synchronization and therefore might cost additional resources and instructions.

  • @tirthasg
    @tirthasg หลายเดือนก่อน

    Nice explanation! By the way, what font-style, and colour-theme are you using? It looks pleasant to the eye!

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Thanks! The font is Fira Code. The theme that you see in the animations is a custom one that more or less resembles the default vscode one.

    • @tirthasg
      @tirthasg หลายเดือนก่อน

      @@CodeForYourself Thanks!

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      @@tirthasg sure, anytime!

  • @alifimtiaj5206
    @alifimtiaj5206 หลายเดือนก่อน

    Great explanation. Liked and subbed buddy

  • @kompila
    @kompila หลายเดือนก่อน

    How can I not like this video. Thank you Igor.~

    • @CodeForYourself
      @CodeForYourself หลายเดือนก่อน

      Thank you so much! 😊

  • @cozycactus
    @cozycactus 2 หลายเดือนก่อน

    what fonts you use in terminal? i liked them

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      I’m not entirely sure which one I used back then but I have mostly converged on using Fira Code everywhere now.

  • @bsdooby
    @bsdooby 2 หลายเดือนก่อน

    I like your (semantic) separation of impl.. inheritance and polymorphic inheritance 🎉

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@bsdooby thanks! I think it makes sense to teach them as separate concepts altogether

  • @alexanderbolinsky6430
    @alexanderbolinsky6430 2 หลายเดือนก่อน

    Fantastic explanations and visuals!

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      Thanks a lot for the compliments! 😌

  • @Pedro-jj7gp
    @Pedro-jj7gp 2 หลายเดือนก่อน

    Nice video! Why is the int* 8 bytes instead of 4 at 1:30?

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@Pedro-jj7gp that’s just the way it usually is on most modern systems: any pointer is 8 bytes. In the end this has to do with being able to address enough places in the memory if this makes any sense. That being said, other systems could theoretically have it be smaller or larger. Does this answer your question?

    • @Pedro-jj7gp
      @Pedro-jj7gp 2 หลายเดือนก่อน

      @@CodeForYourself It does, but I'm a bit confused as I was watching some other videos about vtables and they showed the vpointer taking up 4 bytes... I guess it could just be on that system.

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@Pedro-jj7gp it might be. But you can always check it on your system too. I’ve only ever seen 8-byte pointers on every system apart from really non-standard embedded boards. 🤷‍♂️

    • @Pedro-jj7gp
      @Pedro-jj7gp 2 หลายเดือนก่อน

      @@CodeForYourself Yup, you're right! I just checked using sizeof() both for a regular int* and a vpointer using reinterpret_cast<int*>() and both are 8 bytes. The video in question was 12 years old, maybe it was a 32-bit machine

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@Pedro-jj7gp sounds like a 32 bit system indeed. Glad that it makes sense now 👌

  • @SystemSigma_
    @SystemSigma_ 2 หลายเดือนก่อน

    Nice and clean overview. However, dynamic polymorphism is a very well known and old topic in C++. I would suggest deepening into static polymorphism for the next video. Keep it up, it is refreshing to see technical C++ stuff in TH-cam 2024

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@SystemSigma_ thanks! I actually put static polymorphism before this video, it’s right along a series of videos about templates: th-cam.com/video/1Mrt1NM3KnI/w-d-xo.html Still not the most modern thing but necessary to understand concepts down the line I believe. I also wanted to give an overview eventually of how to do the same things using both dynamic and static polymorphism on some concrete examples. But for that people need to be familiar with both. Does this make any sense?

    • @SystemSigma_
      @SystemSigma_ 2 หลายเดือนก่อน

      @@CodeForYourself It does indeed. I meant that modern c++ features (especially type traits) are really useful for making more robust static polymorphic code. Maybe instead of going too generic with topics, restricting the features scope may be more interesting for experienced viewers.

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@SystemSigma_ I agree that a more in-depth look would suit experienced folk better. My aim here, however, is to fill in the complete playlist that would tailor to somebody who knows nothing about C++ and guides them gently through all the main topics, providing the "why" for using what they learn along with enough information to dig deeper. Please see here for the full list to date: github.com/cpp-for-yourself/lectures-and-homeworks Maybe one day, I will finish the basic course and have some time to dig more in-depth into certain things. That being said, I feel that there is plenty of that type of content on TH-cam already, while the comprehensive courses that I've seen all fell a bit short of what I wanted to achieve here. But we'll see if my course is going to be helpful to anybody 😅

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@SystemSigma_ oh, and just in case you have not seen already, I _do_ talk about type traits a bit more in-depth here: th-cam.com/video/IQ62tA51Vag/w-d-xo.html

  • @danielstromberg
    @danielstromberg 2 หลายเดือนก่อน

    Hi. I think I have the C++ part of this completed, and would like to submit it for testing. But I'm a bit lost on the git side of this. I tried to use the same git template instance, and put my fortune_celler.cpp in ~/src/Full-C++17-course/t/cpp-for-yourself/homeworks/fortune_teller/task in a fresh branch (I also tried it in the same branch), but upon push'ing that to origin, I just got the example_homework graded again. Any suggestions?

  • @McDonaldIbekwe
    @McDonaldIbekwe 2 หลายเดือนก่อน

    Thanks for the video. Please, can you focus more on Modern C++. Here are some: 1. Coroutine 2. Multithreading/Concurrency 3. Testing

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@McDonaldIbekwe ok, so there is one video on testing that I did before but it is not in-depth. As for coroutines I would have to use them in some real projects to be able to speak confidently about best practices that relate to them unfortunately. 🤷‍♂️ I will try to squeeze some multithreading in though at some point but I can’t say when just now 🤷‍♂️

  • @bsdooby
    @bsdooby 2 หลายเดือนก่อน

    structs do not need "public" inheritance; structs are public by default (sorry for being a PITA); you spare a few keystrokes ;)

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      Yes, you are totally right, but I much prefer to be explicit rather than implicit. My logic is that it is not a big deal to type one more word but it allows us to not think about which inheritance is going to be picked by the compiler implicitly should we omit that “public”. Does this logic make sense?

  • @zunoby
    @zunoby 2 หลายเดือนก่อน

    Чудова лекція. В майбутньому було б цікаво почути щось на тему concurrency, threads загалом.

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      Дякую! Радий, що сподобалось! Подивимось, взагалі план був про це розказати, але це така велика тема і в ній так багато чого відбувається, що я не впевнений що зможу її просто і добре пояснити. Але вона у мене в планах. 👍

  • @bsdooby
    @bsdooby 2 หลายเดือนก่อน

    nitpicking: if you use UML for you examples, the impl. arrow (realization of an interface) has a non-filled arrow head.

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      Yeah, I thought of fitting to the standard UML style but then left it at that considering that the tools I used for creating the visuals did not have a non-filled arrow 😅

  • @falol13
    @falol13 2 หลายเดือนก่อน

    SPOILER: Wrapping everything up with the Image class example from the start was a very nice move 👍 I really enjoyed this lecture and will definitely recommend this further. Thanks a lot for your awesome content! 👏

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      Thanks! I’m really happy that that move clicked. It was a long video so I wanted to end at one consistent example that would be relatively close to real life. 🙏

  • @AzerAnimations
    @AzerAnimations 2 หลายเดือนก่อน

    Haven't watched this yet, but I know it is good! One of the best C++ creators out there for sure!

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      Thanks for your support and such a trust in me 🙏 But feel free to revise once watched 😉

    • @bsdooby
      @bsdooby 2 หลายเดือนก่อน

      true words

  • @CodeForYourself
    @CodeForYourself 2 หลายเดือนก่อน

    This video took A LOT of time to make. Just the script I had to rewrite like 3 times. So, if you like what you see, please share this video with your C++ inclined friends if you found this video useful. 🙏 And do leave a comment, this way this video will be shown to more people apparently 🤷😉

  • @GeorgiosMATZARAPIS
    @GeorgiosMATZARAPIS 2 หลายเดือนก่อน

    Pure joy. Thanks!

    • @CodeForYourself
      @CodeForYourself 2 หลายเดือนก่อน

      @@GeorgiosMATZARAPIS thanks man 🙌