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
🚀📈💻🔥 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
2 ай бұрын
Can you please do video about features in c++11 c++14 c++17 c++20
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.
Your teaching style is so easy to follow. Thanks for your hard work 🙏
@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
3 ай бұрын
@@CodeBeauty people like yourself a great role models for those like me. I’m glad the KZread algorithm recommended your videos to me.
great as usual, I'm looking forward to the rest of STL videos, your explanations are excellent
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
can't tell you how much is this useful and well explained, but I guess you already know that :D thanks from Canada
always happy to see your new video, so useful, thank you
Two-hour classes about the STLs are beautifully finished in 20 minutes.
excellent explanation, I'm getting better and better at coding every day, mainly thanks to you
you made a developer of me, I'm forever grateful :)
It looks like a great introduction in templates. I started understand them now.
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🤗😁!!
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.
Very very clear and easy to understand! Couldn't thank you more!!! Can't wait for the next episode~!!!!!
quality content, just what I expected from you 👍
I was waiting for this, thank you Saldina :)
Thank you for uploading again!
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.
Great Video
Nice and well explained video :)
Thanks!
@CodeBeauty
2 ай бұрын
Thank you 🥰
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?
what font do you use? Do you use Consolas?
Can i ask you how can make site from c++ please we need course
So the template function goes right above the function? And it only applies to the function right below?
@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
3 ай бұрын
@@CodeBeauty, oh sorry, keyword, DOH!!
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 /
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
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
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.
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
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
3 ай бұрын
@@gower1973 So Rust has a small advantage allowing to clarify which types can be supported.
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
Ай бұрын
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. 😄
cout
Hi, Saldina kindly provide the discord link.
PLEASE UPLOAD NEXT VIDEO SOON
❤❤❤
Auto replace template I think in c++20 if I’m not wrong
Waaaauw❤❤❤
@CodeBeauty What’s your OF?
🧡🧡🧡🧡🧡🧡
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
3 ай бұрын
Can you please provide your code for this?
Can My Code Make Ethan Cry? Huaa..😱
I've got a better job thanks to your videos, wanna share my paycheck? :D