📚 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 🚀📈💻🔥 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. #include #include using namespace std; bool ascendingCompare(int a, int b) { return a < b; } bool descendingCompare(int a, int b) { return a > b; } void sortAscending(vector& numbersVector) { for (int startIndex = 0; startIndex < numbersVector.size(); startIndex++) { int bestIndex = startIndex; for (int currentIndex = startIndex + 1; currentIndex < numbersVector.size(); currentIndex++) { // We are doing comparison here if (ascendingCompare(numbersVector[currentIndex], numbersVector[bestIndex])) bestIndex = currentIndex; } swap(numbersVector[startIndex], numbersVector[bestIndex]); } } void sortDescending(vector& numbersVector) { for (int startIndex = 0; startIndex < numbersVector.size(); startIndex++) { int bestIndex = startIndex; for (int currentIndex = startIndex + 1; currentIndex < numbersVector.size(); currentIndex++) { // We are doing comparison here if (descendingCompare(numbersVector[currentIndex], numbersVector[bestIndex])) bestIndex = currentIndex; } swap(numbersVector[startIndex], numbersVector[bestIndex]); } } void customSort(vector& numbersVector, bool(*compareFunctionPtr)(int, int)) { for (int startIndex = 0; startIndex < numbersVector.size(); startIndex++) { int bestIndex = startIndex; for (int currentIndex = startIndex + 1; currentIndex < numbersVector.size(); currentIndex++) { // We are doing comparison here if (compareFunctionPtr(numbersVector[currentIndex], numbersVector[bestIndex])) bestIndex = currentIndex; } swap(numbersVector[startIndex], numbersVector[bestIndex]); } } void printNumbers(vector& numbersVector) { for (int i = 0; i < numbersVector.size(); ++i) cout
@hbm293
3 жыл бұрын
Due to the cumbersomeness of the types of these function pointers, they are good candidates for being typedef'ed: typedef bool (*SORT_FUNC)(int, int); void customSort(vector& numbersVector, SORT_FUNC compareFunctionPtr) { .... } SORT_FUNC funcPtr = descendingCompare; // Here in C++11 one could use that "auto" keyword to not have to write the actual type of 'funcPtr'.
@arod3295
3 жыл бұрын
when I used "cout
@giuseppecinque2828
2 жыл бұрын
It is a bubble sort
@kevin_mitchell
8 ай бұрын
@@arod3295 This is my behaviour too, but I'm using the Terminal and not VSCode. cout
@NipkowDisk
3 жыл бұрын
Saldina, I said it in the chat and I will say it here: your videos are well worth watching in my opinion as you are concise, thorough, and pleasant to listen to. Please keep up the excellent work!!
@CodeBeauty
3 жыл бұрын
Thank you so much, I will! 🙏💙💙
@mexxiano
3 жыл бұрын
Saldina! We love you all around the World! Cheers from Argentina!
@lalaff3012
3 жыл бұрын
Cheers from Brazil!
@CodeBeauty
3 жыл бұрын
I love you too! 💙💚 🇦🇷🇧🇷
@luisrobertoflores3278
3 жыл бұрын
Cheers from El Salvadorl!
@iam_mausam
Жыл бұрын
Cheers from India 🇮🇳
@unchris
Жыл бұрын
Cheers from Peru
@shahzahir9990
3 жыл бұрын
It's nice to see you again Mam🙂
@CodeBeauty
3 жыл бұрын
🥰🥰🤗
@MegaAtlus
3 жыл бұрын
After these videos, i'm feeling myself like senior C++ Developer:) Thanks!
@CodeBeauty
3 жыл бұрын
I'm so happy if my videos can motivate you and make you like programming! 🥰🥰🥰
@joebosah2727
2 жыл бұрын
You are just starting
@astudent797
3 жыл бұрын
Awesome explanation
@CodeBeauty
3 жыл бұрын
🙏💙
@muhammadumair6554
3 жыл бұрын
Great videos, hope you complete 100k subscribers soon❣️
@CodeBeauty
3 жыл бұрын
I hope so ☺️ Thank you! 🙏💙
@pkentertainment2143
3 жыл бұрын
Thankyou somuch..i really need this
@CodeBeauty
3 жыл бұрын
You will understand why and when to use function pointers after watching this! 🤗🤗🥰
@pkentertainment2143
3 жыл бұрын
@@CodeBeauty thankyou ❤️🥰
@JC-px9mk
3 жыл бұрын
Thank you for all the videos, they already taught and helped me a lot🥰 and you are kind of someone I look up to soo, just thank you and have a nice day
@CodeBeauty
3 жыл бұрын
Making these videos is a lot of hard work but comments like this bring me a lot of joy! Thank you so much and I wish you happy learning and hope you'll have a great day! 🥰🥰🤗
@streambumper250
2 жыл бұрын
I'm self-learning C++ and your videos are really helpful. This is a very clear explanation about function pointers. Thank you so much for your hard work =)
@phoebewell3653
3 жыл бұрын
I really need this, thanks, it's very helpful
@CodeBeauty
3 жыл бұрын
🙏💙
@herlim6927
3 жыл бұрын
@@CodeBeauty 🙏 love from india
@CodeBeauty
3 жыл бұрын
@@herlim6927 💚🧡🇮🇳
@sanderverhage5148
2 жыл бұрын
Great video, but some aprovements. First a typedef helps a lot with the strange syntax. For example: typedef bool (*Compare_T)(int,int); Compare_T myFuncPtr; Sort( vector& Numbers, Compare_T OnCompare ); Second why don't you pass your compare function directly? Sort( myNumbers, AscendingCompare );
@bene8114
3 жыл бұрын
Saldina. Many thanks for ur courses. One thumb up is not enough.
@CodeBeauty
3 жыл бұрын
Thank you so much! 🙏💙💙
@vishwa2602
3 жыл бұрын
Thanks a lot ...❤️❤️❤️...
@CodeBeauty
3 жыл бұрын
❤️❤️❤️
@lindeanchuang8115
3 ай бұрын
Hi, I am from Taiwan. Thank you very much! Your tutorial is always very clear! I love the style you teach!
@deneristargerian6755
3 жыл бұрын
Love your videos! Your explanations are excellent!
@CodeBeauty
3 жыл бұрын
🤗🥰🥰
@user-ck4yi1hs4x
10 ай бұрын
I used to hate using Pointers but I start to love it now This vid pushes my peak interest further
@nishaternotes
3 жыл бұрын
bool compare(int a, int b){ return a < b;} sort(arr.begin(), arr.end(), compare); I was always wondering how this function works and today I have learned it from you. Thank you for your all videos
@amk2298
3 жыл бұрын
ur voice is very sweet, thanks saldina for this awesome video🙏
@CodeBeauty
3 жыл бұрын
🙏💙
@pedrolobo9835
3 жыл бұрын
Excellent video. I think it's simpler and pratical to call the compare function directly in customSort. Like this: int main(){ vector numbersVector = {4, 2, 1, 3, 6 ,5}; customSort(numbersVector, descendingCompare); printNumbers(numbersVector); system("pause>0"); }
@julyordinary7538
2 жыл бұрын
Best part is real life usage examples so really nice video
@Ghisisan_
3 жыл бұрын
Great video! Function pointers make sense and can be usefull but I really never heard of function pointers until now, even though I studied computer science(about 18 years ago)... 😁 Thanks for teaching me new things about programming.👍
@CodeBeauty
3 жыл бұрын
Yep, they are very useful. I use them very often when I want to invoke a method of the parent class from the child class 🤗🤗😃
@daniloheat
2 жыл бұрын
Callback functions have always been a problem for me as I learn them and immediately forget them. But your explanation is very straightforward and I finally learnt what each part of the syntax is doing. Thank you very much. Keep doing these great videos.
@jhordyperez1594
3 жыл бұрын
excellent video, little by little I'm starting to love this girl, because of how smart she is and the dedication that she puts into each video. Thank you for taking the time to publish this kind of videos. much that helps many of us to better understand ......
@CodeBeauty
3 жыл бұрын
Thank you for supporting me! It requires a lot of hard work to prepare, film, and edit the videos, but it also brings me great joy! 💗💗💗
@MrPassy4u
11 ай бұрын
Been 20 years ago when I wrote my last c/c++ program at school. But this serie makes me want to code some old school tasks
@shashankcool
2 жыл бұрын
Thanks Saldina for explaining the function pointer concept with proper example. Please keep making such videos.
@tarnished_ofTheCGPA
Жыл бұрын
i can not believe how easy you made it , thanks a lot ❤
@samuelholmes4547
10 ай бұрын
I'm a C++ beginner and this was well done. This was very easy to follow and I will be tuning in for more videos.
@anwar6971
3 жыл бұрын
Very well explained. I understood very well.
@CodeBeauty
3 жыл бұрын
🤞🤗🥰
@remimonsel9944
7 ай бұрын
This video is such a good one. I spent 2 hours trying to do the function as a parameter until I think of this video and solved my issue in 4 minutes. You’re awesome Saldina ❤
@CodeBeauty
7 ай бұрын
❤️❤️💪
@yt_bharat
3 жыл бұрын
Your accent is really sweet ❤️ and Saldina you rock 😎
@CodeBeauty
3 жыл бұрын
🙏💙💙
@remimonsel9944
2 жыл бұрын
Function pointers are awesome. That's programming art. Every time, I think I know everything but luckily with you and your channel, there is always something more.
@tuazulyrojoeljean
Жыл бұрын
Yep, definitely very helpful, thank you very much, Saldina!
@Lmn168
3 жыл бұрын
thanks for the 10 hour course and everything
@CodeBeauty
3 жыл бұрын
🙏💙
@thedishmastersa
Ай бұрын
I love you and your videos, please keep on teaching us.
@nezbrun872
Ай бұрын
FWIW, function pointers have very practical use in embedded systems e.g., for dynamic interrupt callbacks, and as performant alternatives to lengthy case statements in state machines.
@tomwellington4255
Жыл бұрын
I have found your C++ videos very down to earth and really easy to understand. Thank you!
@rafiullahafridi11
3 жыл бұрын
One of the best instructor Ms Saldina..... I am ur subscriber from Pakistan
@sirmovielover
2 жыл бұрын
Thank you. My professor assigned a function pointer assignment, but he didn't have time to really explain it. This really helped :-)
@yassinekhadiri6829
2 жыл бұрын
Thank You For Your Amazing Explanation :)!
@user-li7wn6qv7e
Жыл бұрын
i already know about function pointer but I got so much clarity in this video that I was missed. You are great...in simple Function pointers are used instead of switch case (i.e) to reduce the code
@Tonboswimmers
2 жыл бұрын
unbelievable again, learnt so much from your this example, initially I feel lost trying to catch up with all the codes nest, now with this more complicated one, I get to see how it all flows. Never miss a lesson to learn from her, very well put together.
@CodeBeauty
2 жыл бұрын
Happy to hear that ☺️🤗
@anjalililhare7128
Ай бұрын
Amazing example. Thank you
@burakabdulbakiulu
2 жыл бұрын
Idk you have took any diciton course but you have a very smooth explaination.👍 Thank you very much.
@TheJacov
3 жыл бұрын
What did I learn? Two things. 1. The code builds and runs, but it generates about a dozen warnings so I had to track down the problem to get rid of them, I prefer code that doesn't generate warnings. 2. If you want to run both sorts at the same time, you must use two different pointers, that was an easy fix. Problem 1 was harder to track down but I figured it out. It seems that the .size function returns unsigned values, while the loop variables are signed and the < causes complaints. The solution I came up with was to type cast the loop variables in the comparison part of the for loops to (unsigned), this made the warnings go away and made me happy.
@greciahernandez5422
9 ай бұрын
Thank youu!! your explanation is really clear throughout
@denisdobra3627
3 жыл бұрын
Omg you are the best programming 'teacher' on youtube
@CodeBeauty
3 жыл бұрын
Thank you 🥰🥰 Fun fact, my programming teacher's name at University was Denis 😃😃
@typhoond4499
3 жыл бұрын
Exactly what I needed. Thank you very much Saldina!
@CodeBeauty
3 жыл бұрын
🥰🥰🤗
@acceleratorlevel645
Жыл бұрын
Hey thanks for the great explanation and where to use it, i kinda knew the syntax of func ptr but wasn't sure where to use them, this helped a lot!
@swayam50
3 жыл бұрын
You're amazing, thanks for keeping the spirit of C++ alive ❤️❤️❤️
@CodeBeauty
3 жыл бұрын
❤❤❤!
@ravulaakhilsurya8569
3 жыл бұрын
Hey saldina ,your student here from KZitem community requesting you to make Code reading vlogs on c++ You can ask us (your subscribers) to send their codes to you so that you can explain better way of writing the same code for the questions 🙋🙋🙋
@smoothoctopus
3 жыл бұрын
the countless embedded code I've read through and copied and pasted that refused to work because of missing functions that pointers were looking for...I never understood the problem until now...Thank you for the detailed video and the channel, I'm slowly working through all your tutorials!....Beyond that..uff that accent
@rolandocruz15
9 ай бұрын
Made perfect sense to me. Thank you for putting this video together. The concept is complex, but you made it very easy to understand. I am now subscribed to your channel!
@musolodemiano7982
2 жыл бұрын
Your videos are really nice and enchanting
@mahdavimail
4 ай бұрын
This one was good training+usecase thanks
@CodeBeauty
4 ай бұрын
You're welcome 🥰
@peacefuldeityspath
3 жыл бұрын
Omg thx i really needed this for my memory Editor gui :D
@CodeBeauty
3 жыл бұрын
🤗🤗🥰
@yash9725
2 ай бұрын
understood! thanks for the video!
@astet
3 жыл бұрын
my 2 Year c++ in University was a lie. I love your Videos. Can you please make video about Iterations please!
@shrinivasgadade5153
3 жыл бұрын
your videos are simple and concise and make us love programming, thank you for such awesome videos.
@alifawzi8197
3 жыл бұрын
keep the cool work that you doing miss saldina
@jasonchen9713
3 жыл бұрын
why do we need to vector& numbersVector, & here? any previous video cover this?
@holyshit922
2 жыл бұрын
I use function pointers when i write list (sorted instert function or sorting function) or a program for numerical integration (fe with rectangles, trapezoids, or Simpson)
@nigusdibekulu5215
3 жыл бұрын
Love u saldina❤❤, u r the best. from Ethiopia
@kayd2143
Жыл бұрын
Great video, easy to understand. I understood what the code that I thought looked complex in your video meant and I surprised myself. All thanks to your explanation
@ucNguyen-hg2xz
3 жыл бұрын
Very nice
@CodeBeauty
3 жыл бұрын
Thanks, but how did you find this video? 🧐😲 It is still unlisted 😁😅
@ucNguyen-hg2xz
3 жыл бұрын
@@CodeBeauty Really? I've finished it :3
@TheJacov
3 жыл бұрын
Oh yea, I have to agree with Denerius Targerian, your videos are very informative and easy to follow.
@stefanopilone957
3 жыл бұрын
Thank You, very clear explanation, so I could recap qsort() function
@CodeBeauty
3 жыл бұрын
🤗🥰🥰
@ethangold4900
2 жыл бұрын
I'm a beginner in C++ and I think I wouldn't get function pointers in my first try if I was on my own.. I first heard about function pointers in this video (the last video in your pointers playlist) and I learned a lot, thank you so much P. S. Your videos are great overall, not just this vid, so I subbed
@sergeistalarkin7969
3 жыл бұрын
Спасибо ^_^
@CodeBeauty
3 жыл бұрын
Пожалуйста 🤗🥰🥰
@khavovan8201
2 жыл бұрын
So easy to understand. Thank you so much!!!
@Kinsey_
3 жыл бұрын
I love your videos! Please continue to make them. It’s a good supplement to class.
@CodeBeauty
3 жыл бұрын
🙏💙
@SimpleY_
3 жыл бұрын
Can you please make a video about short-cuts in Visual Studio? I see that you often use short cuts, for example to multi-line comment. Short cuts can save us a lot of time, but many people don't know how to use them. Thanks in advance!
@CodeBeauty
3 жыл бұрын
That is great idea. I'll definitely make that video in the future 😃🤗🤗
@mba2ceo
10 ай бұрын
Standard library header please explain
@HengOngHuatAh
2 жыл бұрын
Thank you so so so much!!!
@inayatkhan2061
3 жыл бұрын
Can you make videos where you explore famous c++ libraries and the most important options that they offer?
@boko7654
3 жыл бұрын
Hello, I hard a really hard time trying to understand direct and copy initialization. I couldn't tell the difference between: int a = 4; int a(4); When the compiler reaches int a = 4;, does the compiler first declare the variable a then the literal gets copied to a? The most confusing part is that there are braces as well. int a{4}; I couldn't tell if I should use with brackets or braces in this case. I would be highly appreciated if there will be a video dedicated to this soon. Your layman's terms explanations are spot on.
@user-bu8mg7uq3s
2 жыл бұрын
amazing explanation
@per-erikjansson1774
2 жыл бұрын
Great with simple explanations, I think the use of std::function may also have been commented. I have used that especially inside classes instead of pointers to member functions.
@dominiclogue5924
3 жыл бұрын
Thank you for this great video.
@CodeBeauty
3 жыл бұрын
🤗🥰🥰
@painsme2
3 жыл бұрын
Very useful. Thanks!
@CodeBeauty
3 жыл бұрын
🤗🤗🥰
@anhtravu
3 жыл бұрын
Thank for your sharing, that very helpful. Could you please make a season sharing the callback function ? Why callback functions should be static ? Thank you in advance !
@moularaoul643
3 жыл бұрын
Thanks!!!
@CodeBeauty
3 жыл бұрын
❤️❤️❤️
@programthis3805
7 ай бұрын
at the end why dont you just pass in the function without the ()? good video made me really get it
@rafiullahafridi11
3 жыл бұрын
Please start c# tutorial also
@ramachandrunichandana253
3 жыл бұрын
Please explain function pointers implementation using classes and methods
@angel_machariel
2 жыл бұрын
Is there a special reason why - in Main() - the sort order function is passed to a functionpointer, and then the functionpointer is passed as a parameter to another functionpointer? You might as well pass the sort order method straight into the second sorting algorithm parameter. Why the extra indirection?
@ShayHowardBennett
3 жыл бұрын
Another banger Sald, keep it comin!
@samuelseshadri3337
3 жыл бұрын
Hi Saldina. Please do a video on friend function, inline, and Virtual function in detail
@CodeBeauty
3 жыл бұрын
This video should help you understand virtual and pure virtual functions kzitem.info/news/bejne/tW6cmpWgrXiGbJw 🤗🤗
@samuelseshadri3337
3 жыл бұрын
@@CodeBeautyPlease on friend function too .... 😊😊
@samuelseshadri3337
3 жыл бұрын
@@CodeBeauty It's very hard for a learner to find a tutor like you if KZitem wasn't there at present. Please do more videos on C++ so we could all learn many more concepts which were not taught at University level. I learnt many things from you than my university classes. Thank you Saldina (Beauty with brain 😀)
@wcchang3321
2 жыл бұрын
Great video!
@christiancarter255
2 жыл бұрын
I'm guessing that without the parentheses, we'd output to the console the address location (from RAM) of the function. 2:55 Oh! I was right! :) That's pretty cool. This was a very good and practical use of function pointers. I was experimenting with them, but hadn't imagined that this could be done with them! :)
@Mohammed-zp5sj
3 жыл бұрын
Good 👍 I love what you do
@virgoash7775
3 жыл бұрын
Thanks 😌.
@fireballgfx
3 жыл бұрын
Ok now I'm able to build a while loop with a function pointer call inside. All fired methods have to take care to change the address of the function ptr to that method who have to be called next. In the case I would like to pass some variables I will use a void* - that sounds great!
@OzzFan1000
3 жыл бұрын
Any chance you might consider doing some intermediate programming tutorials? Like one step up from beginner?
@CodeBeauty
3 жыл бұрын
Can you suggest some topics that you'd like to see in the future 🤗🤗🥰
@OzzFan1000
3 жыл бұрын
@@CodeBeauty maybe the basics of setting up a GUI in Windows? Like what the basic structure is for creating a window class? Or if that's more on the advanced side, perhaps showing how to customize a Visual Studio C++ windows starter application?
@kasundinesh
3 жыл бұрын
Hi Saldina, Can you do a series for design patterns?
@sabyasachisarkar2794
3 жыл бұрын
You look so healthy would you plz share your health routines besides all these awesome tutorials??!!
@entertainment9625
2 жыл бұрын
i like your glasses saldina hahah im zouhir nice to meet you !!
@rustycherkas8229
2 жыл бұрын
To describe the syntax as 'difficult' may be off-putting to newbies. Better to simply explain that the parentheses prioritises binding the 'pointer' token ("*") to the name of the function BEFORE dealing with the parameter syntax that indicates a function is being declared/defined. char * func( void ); // "func" is the name of a function because of the "()" that follow that token. (It returns a pointer to a char.) char (* func)(void); // "*func" is the name of a POINTER, and the following "()" indicates that it points to a function. (It returns a char.) This is no more difficult than the algebra in which 5 + 10 * 2 = 25 and (5 + 10) * 2 = 30... Explicit precedence...
@arod3295
3 жыл бұрын
when I used "cout
@st0nks225
Жыл бұрын
did you find out why? XD it happened the same to me now
@mytechnotalent
3 жыл бұрын
In your print function would you want to use a const reference to ensure nothing is changed? I could be wrong but wanted to check. GREAT video very helpful for function pointers and quite efficient.
@CodeBeauty
3 жыл бұрын
It is a good idea. If the job of the function is just to write out elements it shouldn't change them, and to make sure that they'll not be changed we can use const 🤗🤗
@mytechnotalent
3 жыл бұрын
@@CodeBeauty Thank you Saldina!
@billjohnes9380
3 жыл бұрын
@@CodeBeauty We can also use a range-based for loop. ;)
Пікірлер: 247