📚 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.
@remysalone2 жыл бұрын
I am now a university freshman from China majoying in Network Security. I started to learn C++ when I was in high school but gave up due to its complex concepts. Now that we have to learn C++ in my major, I turned to this video to help. Your explaination is really clear and the words in this video is amazingly understandable for a Chinese whose mother tongue is not English. Really thanks you a lot and wish your channel will become better.
@francescofaccodelagarda54083 жыл бұрын
Thank you SOooooo much, Saldina!!! I used to be a wizard in C++ (back in the 1990's ..) ... havent used it for 30 years and you are the best "refresher" I've seen! A pleasure to follow you: charming, whitty, clear .. well done!
@Apost8219 ай бұрын
I am from Ethiopia . I am second year Hawassa university student .I woud like to say , thank you for your great helping for us.I get great knowledge from you
@roninhacked20454 жыл бұрын
hey code beauty your tutorials are so understandable so please can you bring about competitive programming course
@justbake72393 жыл бұрын
Why haven't I seen this channel sooner. Your tutorials are so helpful thank you!!!!
@hussainaqeel73713 жыл бұрын
Hey guys! I have a tip, instead of passing a type parameter and checking for different possibilities with a switch statement, you can use a C++ "template", they allow you to pass type arguments to functions! template // `T` will be the data type void print(void *ptr) { cout
@dealvin3 жыл бұрын
The "" Is redundant, compiler understand types. Good advice, bro
@AK-ey5ms2 жыл бұрын
Why would you do something like this? template void print(T* in_ptr) { std::cout
@kolbe64362 жыл бұрын
Nice
@WolfsdenxD3 жыл бұрын
Thank you so much, you've taken away a lot of my confusion about pointers.
@stefanfrei61993 жыл бұрын
i assume this code is only theoretical, and in production you would use function overloading? void print(int* val) { cout
@maryamzia78313 жыл бұрын
it will show the address .
@riddlewrong8 ай бұрын
cout
@ariverasandoval3 жыл бұрын
You are very good at teaching . Thanks a lot
@ramazanhusaini35313 жыл бұрын
i do appreciate your work for making clear and understandable videos about pointers
@JazzInATinCan Жыл бұрын
Have watched a couple of the pointers videos now - great content!
@kttthn3 жыл бұрын
Thank you so much for your work!!!
@dandon.3667 Жыл бұрын
You are the best teacher 💙💙
@dealvin3 жыл бұрын
Struct and void pointers are powerfull!
@TehCruiser3 жыл бұрын
We can simply use the keyword auto to print a pointer of any type, like: #include void printPtr(auto* ptr) { std::cout
Thank you so much for this amazing series of pointers.
@RustyRustacean4 жыл бұрын
Hi, I learned a lot about C++... thanks! But i don't get something, how can everything I learned be useful, could you make some mini-projects about real world applications in the most realistic way possible (So that I get the idea about what is it to work like a C++ programmer)
@jason_skillman4 жыл бұрын
Thanks that cleared up all of my questions on void pointers 🎉👍
@adrienc87166 ай бұрын
very clear ! Thank u very much
@projetistadegambiarras4 жыл бұрын
excelente tutorial muito bom .
@sousavann2 жыл бұрын
Thank you! It's easy to understand. Can you also make tutorial for different programming languages as well like Java, Python, Javascript, etc. ?
@lucianbetke3 жыл бұрын
Hübsch und klug, gefällt mir.
@softwaresolutions31112 жыл бұрын
Love the way you teach
@tuazulyrojoeljean Жыл бұрын
Thanks, this vid is actually so well explained
@mytuberam3 жыл бұрын
Is it possible to avoid the 2nd argument 'char type' and instead get the type from the first argument somehow?
@manjeet_rajput_95188Ай бұрын
Hey there, I think the template performs a well and easy way to write code this problem.
@gusromul33563 жыл бұрын
girl, you rock! congrats to you and your team... if there is such
@CodeBeauty3 жыл бұрын
No team, only me 😅☺️ Thank you 🙏
@gusromul33563 жыл бұрын
@@CodeBeauty whoa... then you rock and roll ;)
@unisonunison9789 Жыл бұрын
Hey nice video! i just wanted to mention that on 8:34 i had problems with understandings the difference between *((int*)ptr) and (int*)ptr. becasue it was too fast for me. But in the end i unnderstood it. Here is a code for anyone who are still struggling: int number = 42; // Initialize an integer variable 'number' with the value 42 void* ptr = &number; // 'ptr' points to the address of 'number' int* intPtr = (int*)ptr; // We cast 'ptr' to an 'int*' pointer int value = *intPtr; // We dereference 'intPtr' to obtain the value '42' so how i understood it is that *((int*)ptr) casts the datatype to an intiger and to acces the value you need to write the * ((.... in the end
@lukesky9627 Жыл бұрын
*((int*)ptr) means its cast into an int pointer (the inner parentheses containing "int*") and the entire thing is dereferenced, thats why there are the outer parentheses and the "*" at the beginning. Write it out to the console and you will see the difference between *((int*)ptr) and (int*)ptr.
@kelvinwilliams29083 жыл бұрын
I have 2 questions - (1) On lines 4,5,7 & 8 you use "Ptr" but on line 10, you use "ptr", why? (2) At 5 mins into the video, you have 2 funtions, one for "int" and the other for "char" and when you run the program it outputs number 5 and letter a which is fine. Then around 11:30 mins into the video you have the "void function" which does the same thing - but the code for the two original functions is still there so how does the computer know which functions to use because now there are three functions to chose from. What is it that I have missed here?
@everline_builders3 жыл бұрын
Thank you! Excellent video! But can we use auto* in lieu of void* ?
@tayabfarooq75443 жыл бұрын
@code beauty! in one of your videos you had shown the method of sorting variables inside an array ....... Kindly provide the link to this video as soon as you can.... I had ever watched it but now I could not find it!
@sv3glx4 жыл бұрын
Once again.. Awesome!
@strategyschool7 күн бұрын
So how about using template before writing function an use for the arguments?
@fatiqhussnain83992 жыл бұрын
saldina ! i appreciate your work but plz make a detailed video on link lint in c++
@Wexler1112 жыл бұрын
Huge thanks for these videos
@hell0kitje4 жыл бұрын
Im struggling with pointers and arrays, hope it will be covered in future
@CodeBeauty4 жыл бұрын
Yep, I will make a video about that as well 😊
@menu67503 жыл бұрын
great lesson..🙂 Should i make "switch case" for every data types..i want to pass to the void pointer..
@aditisingh49523 жыл бұрын
Hey Saldina ! why did you make the type char??
@hama_kurdish2434 Жыл бұрын
You can use template after that create a function to hold every data type.
@viniciusmelo9843 жыл бұрын
11:28 I believe the "break;" statement is missing
@MihaiDumitrescu123 жыл бұрын
As a joke I only understand "avoid pointer" :)
@imtiyazalam_IIItian2 жыл бұрын
thank you maam for such nice explanation....love from INDIA
@Dani-mp2we3 жыл бұрын
using void pointers is a better solution than function overloading? in terms of performance
@AbdulRehman-ch4kw3 жыл бұрын
Thanks... This was Very Useful :)
@liquidred2573 жыл бұрын
is the break command in the switch necessary, because won't type fail the other cases if it passes one?
@AviPars2 жыл бұрын
Do you have a video on fn pointers
@agnisri1201 Жыл бұрын
Finally i rewire my brain ❤
@noonegates23283 жыл бұрын
isn't it better to use: case 'i': cout
@degenpokerGG10 ай бұрын
That's correct. While both approaches technically accomplish the same task, using static_cast is generally preferred in modern C++ code because it provides stronger type checking and better readability. It's a good practice to use the type-safe features provided by the language whenever possible.
@matthewurke51924 жыл бұрын
Hey, question. You said something about a logic error. But if you type out each case for each type, could the program run anywhere you need it to in your code, by reference the void code again at lets say line 300, and line 3000?
@CodeBeauty4 жыл бұрын
Yes, you can invoke "print" function as many times as you want. Are you familiar with the concept of functions? I did a short series about functions in C++, that can help you understand this better. And a logical error is related to the error that your compiler is not able to see, but it will cause your program to behave in an unexpected way. For example, a logical error can be if you try to calculate how many seconds there is in a day, and instead of calculating 24 (h) * 60 (min) * 60 (sec) you do something else. Your compiler will not know, but you will get the wrong result.
@emaus83443 жыл бұрын
I was trying to find out what is IntPtr datatype and came upon your video. Is function that you wote explanation for IntPtr or have I got something wrong?
@neck-o Жыл бұрын
I just realized that you don't even need a switch statement to determine the datatype of the passed pointer. Just declare a template above the function: template , and use whatever datatype passed with the function as the pointer to cast as: func(&anInteger), then inside the function: cout
@Peter-lq1xj4 жыл бұрын
Amazing
@michaeleddy927 Жыл бұрын
What is the switch function for?
@AlexTrouman-oi1yp Жыл бұрын
in switch what about default !!!!!??
@hefhef543213 жыл бұрын
Here's an alternative way for doing this but with generics and templates ``` #include using namespace std; template void print(void* _ptr); int main() { int n = 5; char l = 'a'; print(&n); print(&l); system("pause>0"); } template void print(void* _ptr) { cout
@madhusankawijerathne8435 Жыл бұрын
Thank you beauty!
@alejandromackay30742 жыл бұрын
Break is missing in the switch-case structure.
@yahiamohamed47642 жыл бұрын
you can use an auto type pointer so it can handle any type
@miguelferreira-xy7gq2 жыл бұрын
merci thank you
@remimonsel99442 жыл бұрын
instead of using a void pointer, can't we use a template and typedef to create a sample function ? or my idea is not so good for some reasons ?
@arisgacha296 Жыл бұрын
very good.
@muadrico4 жыл бұрын
Looks more like a C approach than a C++ solution. In C++ you would make “print” a templated function or use a std::variant as the type. Usually you don’t need “void*” in modern C++. Also, using C style typecasting usually is a code smell in C++.
@Novecento4 жыл бұрын
Yeah you're right, but I think the point of this video is to teach beginners what void pointers are and how to use them and I think she did a great job at that in only 15 minutes. Void pointers are just a tool, a legacy tool but I think beginners should know them because probably they'll have to deal with legacy code more often than they would think.
@muadrico4 жыл бұрын
@@Novecento Agreed.
@carloni19973 жыл бұрын
I agree that void pointers are not usually needed. However, I do wonder why you would call C style cast a code smell? If you know what you're doing, a cast is a cast. Right? char carr[4]; int *ptr = (int*)carr;
@muadrico3 жыл бұрын
@@carloni1997 It can lead weird behavior, when used for casting objects in a class hierarchy and the compiler can not spot the error whereas if you use the correct C++ cast, the compiler will tell you the error. Here is a nice article about the different kind of casts. arne-mertz.de/2015/01/a-casting-show/
@carloni19973 жыл бұрын
@@muadrico I agree it can lead to weird behavior. Simplest possible weird thing would be: float fval; int *ptr = (int*)&fval; (*ptr) = 5; Weirdness here would come from a fact floats are stored differently than integers. I also like article you shared. Examples and explanations. Thank you. It was a worthy read. And it gave me a little bit to think, so with that in mind, I would say this: C++ casts are used for safety, since they can trow exceptions and compiler errors. But if you really know what you're doing, C style casts are totaly legit. And if you really, really know what you're doing, C style casts shouldn't lead to weird behavior. Oh, and my favorite part was: Downcasts in class hierarchies. P.S. B2* pb2 = (B2*)((void*)&d); gives me the same result as a static_cast
@muhammadumernadeem7254 жыл бұрын
11:25 Break statement is missing
@CodeBeauty4 жыл бұрын
Correct 😊
@Fullstackdev-2 жыл бұрын
thanks
@hoangphan24983 жыл бұрын
nice tks a lot
@serollakrish38332 жыл бұрын
hello mam can explain about null pointers, where and when we use null pointer, main reason to use null pointer ...... plz mam
@zareenabanu64253 жыл бұрын
11:27 question Answer: Break;
@bigmac9634 жыл бұрын
Hi, please can you do a video tutorial on how to build a simple game in c++ console. Thanks!
@StabbyMacStabStab3 жыл бұрын
Am I wrong for thinking that it would be better to just use a template function to deal with the different data types being passed in instead of having to use a void pointer with a bunch of switch statements?
@vivekdixit92084 жыл бұрын
I have just started to learn C++ from your first video .. I know some basics of C so can guide me the sequence of your tutorials and how much days it will take to understand the codes written in C++. It will help a lot .. thanks in advance and thanks for doing such great videos .
@CodeBeauty4 жыл бұрын
In my opinion, in programming, there is no final goal to achieve where you can say "Okay, I know enough, I'm good now" This is the kind of profession where you learn every day. So take it easy, be consistent, but don't be hard on yourself, and enjoy the process of learning each day. Before you expect it, you'll be able to look back and say "Well, I feel like reading/writing code became like reading/writing English" I remember a few years ago when reading code felt like trying to understand hieroglyphs. I couldn't wait to become "good" and not have to struggle with that anymore, and then I decided to stop stressing about it and focus on improving things that I felt were my weak spots, and over time, that feeling of not understanding code or not being able to write it just disappeared. I can't tell you how long it will take, I don't think anyone can, but I can tell you that if you invest 1-2 hrs every day for a year, you'll be able to see huge progress. And you can even take weekends off. 😊
@paulcook7484 жыл бұрын
Nice and clear, but honestly, void pointers are not a "beginners" subject in C++ because the only time one should be using them is in highly advanced situations. I appreciate you are trying to construct an example that is easy to follow, but it concerns me that a beginner might interpret this as a good way to design code. This is the absolute antithesis of C++'s approach to strong typing.
@lizzy_trevisan9 ай бұрын
did we forget the break between cases?
@typedef_4 жыл бұрын
Is it good practice to use pointers in C++ ? To me, an "object" implicitly removes the need for pointers. I've never used C++, but I have used C# a lot and never got in a situation where a pointer was needed...
@findikbabi4 жыл бұрын
11:25 We are missing a break.
@CodeBeauty4 жыл бұрын
Yep. Glad to see that you are still here 🤗
@luser53813 жыл бұрын
Doubt 1: function overloading with different pointers in the signature? Doubt 2: Templates with pointers? like, say typename t which results in parameter void fn(t* var) ???
@yankobzykant55793 жыл бұрын
break statement was missing inside switch case
@saifmos65163 жыл бұрын
but why when i do extra case 'd':cout
@isajameh27893 жыл бұрын
Thank you beauty.
@ravirajac4 ай бұрын
I would suggest to use template void printData(const T &value) { std::cout
@rrokluli73924 жыл бұрын
It would be better if you use a Dark Theme for VS
@CodeBeauty4 жыл бұрын
Some people told me that they have to watch the videos on lover resolutions and that it is much easier to see the code when it is on a light background instead of a dark one. In regular life, I prefer a dark one as well, but because of the reason that I mentioned I use light for videos 😊
@WistrelChianti3 жыл бұрын
singing "it's my memory and I'll cast it to what I want to" (referencing the Leslie Gore song)
@MGD3203 жыл бұрын
what song?
@WistrelChianti3 жыл бұрын
@@MGD320 it's my party
@SulixD3 жыл бұрын
this is more C style really than C++ , in the future consider teaching templates to solve this same problem where you used void pointer.
@onurolce4 жыл бұрын
11:32 I did not watch after that second. I guess you need to finish CASE with BREAK; and also you also need to add DEFAULT in SWITCH function. At lease we are doing it in Java :)
@naimcool364 жыл бұрын
in c++ u dont need default
@CodeBeauty4 жыл бұрын
You will not get an error if you don't have a "default", but if you want to cover some default situation, that is what "default" is meant for 😊
@onurolce4 жыл бұрын
@@CodeBeauty "if any of these conditions not happens then do it..." I guess you are telling this to me in your style, I like it :)
@Superman-tm8cp11 ай бұрын
Why can't we use templates instead of switch? It works better and takes less time to write the code
@markosbasha63873 жыл бұрын
It’s Christmas time, Abebe and Alemu woke up one day and found N presents under their Christmas tree, each present has a unique number from 1 to N, since Abebe love even numbers and Alemu love odd numbers they decided that Abebe will take all the presents that have an even number written on it and Alemu will take all the presents that have an odd number written on it, but they don’t know how many presents they will get each and they are both lazy to count the presents right now so they asked for your help to tell them how many presents each of them will get using a function called “Christmas()“...please help me with this question ....U are my Excellent lecture ❤❤
@ashenhewavithana94793 жыл бұрын
Hi, this is my code for printing out a letter using functions and pointers, but I am getting an error - "invalid conversion from 'const char*' to 'char*' -fpermissive". Could you please help me solve this. Thanks #include using namespace std; void printNumber(int* numberPtr){ cout
@hbbss86844 жыл бұрын
why not use a template instead?
@muhammadmuiz14874 ай бұрын
Break point is missing
@kelvinwilliams29083 жыл бұрын
Regarding my two questions 1 day ago I have now worked out the answer to my second question but I am still unsure about the first.
@cmnikola Жыл бұрын
bro its not important name, two years have passed, how are you?
@huraqandavid67272 жыл бұрын
The part missing in the case is "break;"😅. Im not sure xD let me continue to video