STL Templates in C++ - Generic Functions and Classes (beginner-friendly)

Ғылым және технология

In this video, we will learn about STL templates. I will explain STL templates in C++ and why we need templates.
This video will help you understand the purpose of STL templates, and you will see how to use templates in C++. To help you understand, I will show you the difference between regular functions and template functions. We will also cover template classes with practical examples.
Additionally, if you want to gain more practical experience in building real apps and solving real problems, join my Practical Programming Course below.
🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. ❤️😇
Use the link to make a contribution: bit.ly/CodeBeauty_BuyMeACoffee
Related videos:
My Practical Programming Course (Introduction) - • Learn to Code and Earn...
C++ STL Introduction - • C++ STL Introduction (...
CONTENTS:
00:00 - What are STL templates?
02:19 - Why do we need templates?
03:37 - Solution without templates
06:25 - Template functions (practical example of generic functions)
09:01 - Recap of template functions
09:28 - Let's practice template functions
10:44 - Template classes (practical example of generic classes)
16:23 - Let's practice template classes
18:01 - Summary of the video
Add me on:
Instagram 📸 - / truecodebeauty
Twitter 🐦- / truecodebeauty

Пікірлер: 53

  • @CodeBeauty
    @CodeBeauty3 ай бұрын

    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/ Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time!💰Use this coupon to save 10% (CODEBEAUTY_YT10). Use it quickly, because it will be available for a limited time. 📚 Learn programming with these Free E-Books ⬇ C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook

  • @mizel_1121

    @mizel_1121

    2 ай бұрын

    Can you please do video about features in c++11 c++14 c++17 c++20

  • @KaustavMajumder
    @KaustavMajumder3 ай бұрын

    Could you please talk a little bit about DLL and LoadLibrary and call a function from a ad-hoc loaded module that has been defined with __declspec(dllexport)? Thanks.

  • @1tav0
    @1tav03 ай бұрын

    Your teaching style is so easy to follow. Thanks for your hard work 🙏

  • @CodeBeauty

    @CodeBeauty

    3 ай бұрын

    I'm happy to hear that my video help you, in fact, I'm currently fiming more videos and this message is really motivating because it is not even 7am and I'm already working 😴🥱🥰

  • @1tav0

    @1tav0

    3 ай бұрын

    @@CodeBeauty people like yourself a great role models for those like me. I’m glad the KZread algorithm recommended your videos to me.

  • @codeoasis1180
    @codeoasis11803 ай бұрын

    great as usual, I'm looking forward to the rest of STL videos, your explanations are excellent

  • @milkamilkica1935
    @milkamilkica19353 ай бұрын

    when I watch your video I think I understand everything, than I start coding and I see that I have much to learn, so I return to your videos again :D But I'm improving so just wanted to thank you

  • @user-sw8bq1rk9c
    @user-sw8bq1rk9c3 ай бұрын

    can't tell you how much is this useful and well explained, but I guess you already know that :D thanks from Canada

  • @gollygobih6527
    @gollygobih65273 ай бұрын

    always happy to see your new video, so useful, thank you

  • @sangeeth.47
    @sangeeth.472 ай бұрын

    Two-hour classes about the STLs are beautifully finished in 20 minutes.

  • @sensubean633
    @sensubean6333 ай бұрын

    excellent explanation, I'm getting better and better at coding every day, mainly thanks to you

  • @hazarder-nj9lw
    @hazarder-nj9lw3 ай бұрын

    you made a developer of me, I'm forever grateful :)

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer8473 ай бұрын

    It looks like a great introduction in templates. I started understand them now.

  • @christopherrice891
    @christopherrice8913 ай бұрын

    I am SOOOO looking forward to this video! I feel like i am waiting for my favorite cartoons to start or something! That's how much excitement these C++ videos give me🤗😁!!

  • @austineodhiambo4095
    @austineodhiambo40952 ай бұрын

    Hi! Saldina thanks to you that am now good with Data structure, can you please make a video on socket programming i would really appreciate.

  • @poppylin-zd7ty
    @poppylin-zd7tyАй бұрын

    Very very clear and easy to understand! Couldn't thank you more!!! Can't wait for the next episode~!!!!!

  • @amelccc
    @amelccc3 ай бұрын

    quality content, just what I expected from you 👍

  • @robi23robi23
    @robi23robi233 ай бұрын

    I was waiting for this, thank you Saldina :)

  • @jsrada29
    @jsrada293 ай бұрын

    Thank you for uploading again!

  • @feynman_QED
    @feynman_QED2 ай бұрын

    Very good these videos about templates 💪🏻 I also found in the video the answer to a question i asked recently: that the course's skills can be transferred to another language. Good to know. Pity C# was used and not C++ though. Saldina i know hearing this makes you angry 😂 Good job by the way.

  • @richmorefilms6568
    @richmorefilms65683 ай бұрын

    Great Video

  • @paulovictorcarvalhodeolive2618
    @paulovictorcarvalhodeolive26182 ай бұрын

    Nice and well explained video :)

  • @Kenforbes3
    @Kenforbes32 ай бұрын

    Thanks!

  • @CodeBeauty

    @CodeBeauty

    2 ай бұрын

    Thank you 🥰

  • @rahultom4310
    @rahultom4310Ай бұрын

    Hii , instead of using intClaculator or floatCalculator as the the object of the template class can't we use TCalcultor? Which would be more generic, isn't it?

  • @user-wo2ee6rr7i
    @user-wo2ee6rr7i2 ай бұрын

    what font do you use? Do you use Consolas?

  • @Hack-Life-0day
    @Hack-Life-0day3 ай бұрын

    Can i ask you how can make site from c++ please we need course

  • @chrishabgood8900
    @chrishabgood89003 ай бұрын

    So the template function goes right above the function? And it only applies to the function right below?

  • @CodeBeauty

    @CodeBeauty

    3 ай бұрын

    If you mean the template keyword then yes, and if you put it above the class, then it applies to the entire class, and you can use T as a type on the entire class 😄

  • @chrishabgood8900

    @chrishabgood8900

    3 ай бұрын

    @@CodeBeauty, oh sorry, keyword, DOH!!

  • @mohdhammad4786
    @mohdhammad47863 ай бұрын

    You can use float for both int and float numbers in c and c++: std::printf("%g ,sum(5,7.7)); std::printf("%g ,sub(6,3.2)); / "%g" instead of "%f" to remove zeros which are not beautiful /

  • @timbergus
    @timbergus3 ай бұрын

    Amazing video! Thanks a lot. I have a small question, though. Is it possible to return different types depending on the logic inside the function? Doing this, I got this error: "no instance of function template "choose" matches the argument listC/C++(304)". Is this even possible using templates? template T choose(int key) { int a = 0; double b = 3.14; switch () { case 0: return a; case 1: return b; default: return "Error"; } }

  • @gower1973

    @gower1973

    3 ай бұрын

    You are only passing an integer in so you can only ever get an integer back, you need to pass T as the parameter

  • @timbergus

    @timbergus

    3 ай бұрын

    Thanks @@gower1973. I've been doing some research, and I think a template is not the right tool for this problem. I'm trying using "std::any" and "std::any_cast" to return any type and then cast the proper one where I use it.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer8473 ай бұрын

    But what if '+' isn't defined for some types, or defined, but not what you think? Why do not say that T is a type for a number values?

  • @gower1973

    @gower1973

    3 ай бұрын

    You need an operator overload when trying to add any object that is not an basic type, it doesn’t know how to add the objects you are trying so you have to write your own function to do it.

  • @kamertonaudiophileplayer847

    @kamertonaudiophileplayer847

    3 ай бұрын

    @@gower1973 So Rust has a small advantage allowing to clarify which types can be supported.

  • @manjotsingh2725
    @manjotsingh2725Ай бұрын

    I want to buy your course but it says only for window PC users why is it so ? I got mac should I buy ?

  • @CodeBeauty

    @CodeBeauty

    Ай бұрын

    Unfortunately, we don't have the capacity to offer support for Mac users, and I want my students to have the best possible experience. If you can find or borrow any windows laptop, even an older one, you can enroll. I'll teach in the course how to optimize the apps so that they take less space and memory, so they work even on old laptops, but it must be Windows. 😄

  • @Akas766
    @Akas7662 ай бұрын

    cout

  • @brandonmatsuib3312
    @brandonmatsuib33123 ай бұрын

    Hi, Saldina kindly provide the discord link.

  • @sm_hasib
    @sm_hasib3 ай бұрын

    PLEASE UPLOAD NEXT VIDEO SOON

  • @muhumuzaduncan2961
    @muhumuzaduncan29613 ай бұрын

    ❤❤❤

  • @mizel_1121
    @mizel_11212 ай бұрын

    Auto replace template I think in c++20 if I’m not wrong

  • @jamshidbektursunboev1908
    @jamshidbektursunboev19083 ай бұрын

    Waaaauw❤❤❤

  • @JakubSK
    @JakubSK3 ай бұрын

    @CodeBeauty What’s your OF?

  • @wilgarcia1
    @wilgarcia13 ай бұрын

    🧡🧡🧡🧡🧡🧡

  • @gower1973
    @gower19733 ай бұрын

    I don’t think you need a templated class in this example, surely just a normal class would suffice, the datatype are generic to the functions, here you are creating a class instance for every calculator datatype. It doesn’t make sense, you should only need one instance of the calculator class

  • @CodeBeauty

    @CodeBeauty

    3 ай бұрын

    Can you please provide your code for this?

  • @arahinalif
    @arahinalif2 ай бұрын

    Can My Code Make Ethan Cry? Huaa..😱

  • @lulu_barcelonalulu_barcelona
    @lulu_barcelonalulu_barcelona3 ай бұрын

    I've got a better job thanks to your videos, wanna share my paycheck? :D

Келесі