David, you should have "in depth c++" series created. Keeping such precious knowledge to yourself is a crime :D
@javidx9
6 жыл бұрын
Hi Aleksei, I may do a C++ series next year, it depends, there are already a lot of resources available, but I have been considering doing a short run of "Back To Basics" videos
@TahirGluttony
5 жыл бұрын
@@javidx9 hey dude, really appreciate you sharing the delicate yet easy to understand explanation on such a crucial topic. please make the "back to basics" video :)
@edwin3928ohd
4 жыл бұрын
@@javidx9 it's been a year! i would love a series like this
@maycodes
4 жыл бұрын
@@javidx9 please consider it or Can you share resources ?
@DannyOvox3
4 жыл бұрын
javidx9 please do it, I will be starting a course in it but your KZitem videos will be a life saver I’m sure
@fisher00769
2 ай бұрын
I'm relatively new to C++ and I didn't have much troubles understanding what pointers are, though the syntax was a bit weird, but I really struggled with the question of "Why" would I even need them. Besides being completely obsessive about my memory management, I really struggled to come up with something that I couldn't do without pointers. Your example of polymorphism is absolutely brilliant, and you explained it as well as humanly possible. Thank you very much, I'll be sure to check out your other videos too!
@javidx9
2 ай бұрын
Thanks! Simply, the primary use of pointers is to point at memory! Why move/copy whole objects when you can just use its pointer? It fits in a register!
@rockyrivermushrooms529
5 жыл бұрын
still trying to wrap my head around pointers. This video helped so much! I need to practice because that's how I learn best.
@javidx9
5 жыл бұрын
Its all about the practice, videos, guides and tutorials will only get you so far, at some point YOU need to write the code.
@汉房投资
3 жыл бұрын
very informative, and helped me greatly to understand and more importantly less fearful of use of pointers
@anastasiak8589
3 жыл бұрын
Fantastic approach to presenting complicated information. Great video
@Zakru
3 жыл бұрын
32:03 "Here, we've got Chrome" lol
@RadicalGaming1000
4 жыл бұрын
Thank you. I needed this
@counterculturecocks
5 жыл бұрын
Excellent video! Thank you ever so much.
@javidx9
5 жыл бұрын
Thanks and no problem Assimil8!
@shmueliori2684
5 жыл бұрын
Thanks!!!
@Ureallydontknow
4 жыл бұрын
"basic use of pointers"
@milkjs
3 жыл бұрын
You're teaching this for free when I pay thousands for a shitty explanation in school. God bless.
@Ironlionm4n
3 жыл бұрын
Oof this one hit hard today
@tahwnikcufos
6 жыл бұрын
Probably the single most import concept in C++ to grasp, and even more so, the most butchered topic you'll ever find in books.
@javidx9
6 жыл бұрын
It is indeed a hugely important concept, and it also is important in other languages too, even though it may not be explicit. I think video is a good format for pointer understanding as it shows you things moving around in memory, something a book can only hint at.
@valizeth4073
5 жыл бұрын
Agreed, pointers are seen as this powerful tool that nobody really understands. It is really powerful indeed, but they aren't complex or anything.
@samdavepollard
3 жыл бұрын
@@rockapartie looks like a book i'll find useful - thanks for mentioning it
@joestevenson5568
3 жыл бұрын
@@rockapartie Given that pointers are essentially the same between the two (implicit void* casting aside) it sounds like that might be the go to for c++
@framepointer
3 жыл бұрын
@@joestevenson5568 C also does not have passing by reference.
@joshlovesfood
3 жыл бұрын
This guy is a genius, he is gentle, and wants everyone to learn at their own pace and on their own terms. He explains things like a gentleman and holds no judgement or arrogance towards others. He is in fact a PhD holder in Computer Science, as well as an experienced professional in the real world. It does not get any higher for anyone. He is undoubtable worth his weight in gold. Creative minds like this belong on the edge of technology and business
@WomboBraker
Жыл бұрын
Well said
@OikPoinFive
6 ай бұрын
Grrrr!
@YoomarTuNoOmar
5 жыл бұрын
"I think I have covered all of the most basic uses of pointers in C ++" 41:28 I can not even imagine the advanced.
@mehmetakyuz5290
5 жыл бұрын
rofl tru dat
@arnolduk123
4 жыл бұрын
I think the advanced uses of GOTO would be a good appetizer too..LOL.
@harrymack3565
4 жыл бұрын
21 hours later, 13 skull fractures form banging your head in your desk and wall, mid level brain damage from drinking 92 redbulls, damaged vocal cords from screaming at your screen and your eyes in a constant clash between dryness from looking at a screen for so long and wetness from the pool of tears your formed before your tear ducts where completely empty, you understand the advanced parts if pointers.
@Mateus.007
4 жыл бұрын
int *(*f(void (*)(void *))(void *);
@xrafter
4 жыл бұрын
@@Mateus.007 This is bad and hard to read i hope no one use it.
@_rcs
6 жыл бұрын
This channel is such a gem, thank you Javidx9.
@javidx9
6 жыл бұрын
Hey no problem Rory, thanks!
@Bolpat
4 жыл бұрын
Every time you say "Asterix" for asterisk, I cannot stop myself thinking: Why don't we call "&" the Obelix operator?
@inigo8740
4 жыл бұрын
One is rather small, the other one is round and large. Seems very fitting.
@ng4logic
4 жыл бұрын
That is genius. People should adopt this. Its very easy to remember and it makes sens
@achtsekundenfurz7876
3 жыл бұрын
It's a miraculix nobody thought of that before! :D A few funny names for special characters: # chainlink fence / tictactoe @ paperclip § fidget spinner ! baseball bat ~ wavelet ^ party hat ° halo
@tonyfremont
3 жыл бұрын
@@achtsekundenfurz7876 I just wish people would learn the proper names for (), [] and {} = parenthesis, brackets and braces, with the latter two having the optional modifiers of square and curly respectively, if 9ne must. There's only one set that should ever be referred to as brackets [] the other two are not brackets, ever. ;)
@achtsekundenfurz7876
3 жыл бұрын
@@tonyfremont Tbf, "parenthesis" sounds like an ugly medical condition, so I can understand why few people use that word...
@akashverma4280
4 жыл бұрын
32:05 Chrome: Got some RAM? OS : Actually ther... Chrome : Thanks!
@Leonhart_93
4 жыл бұрын
It can have all of the memory of my PC, if that's what it takes to run at max speed. The OS will afterwards balance it as needed by other programs.
@akashverma4280
4 жыл бұрын
@@Leonhart_93 Chrome takes advantage of OS generosity, lol. What does it need 40% RAM for when only 1 tab is open smh.
@Leonhart_93
4 жыл бұрын
@@akashverma4280 Define 40%. Is it of 4, 8 or perhaps 16 GB? I have 16 GB and 2 screens of Chrome with about 10 tabs each and the total consumption is ~2 GB RAM according to Task Manager. That is too little imo. Certainly not enough to warrant this imfamous reputation I see everywhere. i.imgur.com/MPhDt4T.png
@akashverma4280
4 жыл бұрын
@@Leonhart_93 40% of my 4 Gig RAM on my potato pc. Sorry I'm broke. Multitasking becomes pain in ass. Although I've stopped Windows Update manually to allow some free RAM. I didn't mean to smear the reputation of Chrome. It's the best browser I've ever used.
@gondoravalon7540
4 жыл бұрын
@@Leonhart_93 "That is too little imo. " Too little? What do you mean?
@kamilbizon8317
5 жыл бұрын
I've seen 4+ c++ pointer tutorials, and this one is the best one. You managed to explain the basics really well. I hope you will find time to make more videos covering the basics of c++
@javidx9
5 жыл бұрын
Thanks Kamil! I'm thinking about doing some sort of "C++ Basics" series, but there are a lot of resources already out there. I'll keep thinking about it though for the new year.
@mrhidetf2
6 жыл бұрын
well 22 min in i lost the plot
@javidx9
6 жыл бұрын
Pointers to arrays of pointers, which point to objects created by functions that return pointers to other pointers? What is there to be confused about? :D Seriously though, multiple layers of pointers does become confusing quickly until you train your brain to start thinking about them like any other variable, its just in most languages you are never required to think about memory addresses as a primitive type.
@DimetryB
4 жыл бұрын
Same. And I am trying to parallel translate on my native language what he tells. I feeling like I need to go to school or kinder garden
@FrankenLab
3 жыл бұрын
I agree, all the levels of redirection and trying to remember the correct symbol for it, its like a huge recursive brain fart. Back in the 80's when I did C programming, I'd get thrown off occasionally, but now my brain just goes into drift mode. Just noticed your username, think we had similar ideas, lol.
@mrhidetf2
3 жыл бұрын
@@FrankenLab lmao
@merajjahir2602
3 жыл бұрын
i like how when you are learning the higher level languages you think computers are amazing and stuff, but when you get to learn the lower level languages you realize computers are stupid . i mean it happed to me...
@stackercoding2054
3 жыл бұрын
I was understanding everything (kinda) until 21:15, after that I lost track of what you were doing, I need to rewatch this many times but this is pure gold, I would like to express my deepest thanks to you for taking almost an hour of your life to share this super useful knowledge.
@MikeMcRoberts
2 жыл бұрын
Same here. Exact same point in the video I got lost.
@NN-uy6ik
Жыл бұрын
Same 😂
@jonnymcgrath4816
10 ай бұрын
Same here. You commented/watched this video 2 years ago. How is your programming skill in C++ now? Are you able to understand beyond 21:15?
@jonnymcgrath4816
10 ай бұрын
@@MikeMcRoberts Same here. How is your programming skill in C++ now after a year ago of watching the video? Are you able to understand beyond 21:15?
@barathkumar6903
7 ай бұрын
@@MikeMcRoberts R u Zoro?
@napalmpig3772
5 жыл бұрын
The problem I have with pointers is that as a beginner, you don't know when or why you would use them. I was fine with the concept of storing an address, but at beginner level you aren't writing very complex code and you cant see why you would want to store an address. It seemed like it was just a way to break encapsulation to access some variable. Not to mention the fact that there are references as well which are similar enough to cause more confusion.
@APaleDot
5 жыл бұрын
Pointers are really fundamental, and I would hope that students learn them early. They should be taught as a way to refer to a very large piece of data. For instance, if you wanted to load an entire image from the hard drive, there is no way you could just fit that in a normal variable; the stack is just too small. So, you ask the operating system for a big chunk of memory, and it gives you a pointer to that memory. Obviously, there are other uses as well, but this is the most direct and understandable, IMO.
@edwinmartens509
4 жыл бұрын
Smart pointers.... "Don't leave being smart to the pointers"
@ryanhackett9680
4 жыл бұрын
No, instead leave it to classes which wrap a pointer and provide some useful functionality such as reference counting and automatic deletion. The concept of "smart pointers" in C++ is very vague. Nowawdays we generally refer to weak_ptr, unique_ptr and shared_ptr
@mikze123
3 жыл бұрын
don't use word smart with me
@gondoravalon7540
3 жыл бұрын
@@mikze123 To be pedantic, "smart with me" is 3 words. 😂
@guy-dev
3 жыл бұрын
@@gondoravalon7540 he was kidding, and "with me" part of the sentence, not the word he was saying not to say
@gondoravalon7540
3 жыл бұрын
@@guy-dev It was a joke working off of the grammar/lack thereof. :P
@TheNormalUniverse
3 жыл бұрын
Lol I love the “what are pointers” Art!
@AlexSmith-fs6ro
5 жыл бұрын
I love smart pointers. In a large application, I would rarely use a raw pointer. Should the object get deleted, all other raw pointer that reference are now dangling. No fun to debug if you dereference. A pointer used to reference a newly created object in the free store, in the presence of exceptions, you get memory leakage. I always use a unique_ptr when a object in the heap is initially created, in case of exception later in the code. Great vids, learned loads from you.
@nahbruhwhat
4 жыл бұрын
Excellent! This is as calming as watching a documentary about lions on the savanna!
@TomJez100
5 жыл бұрын
PHENOMENONAL VIDEO!! Very well thought out and presented. Excellent coding examples that reinforce understanding with illuminating graphics. Perfect amount of depth for a real fundamental base in a simple and easy-to-understand manner. A sign of a true expert with much experience who can also teach. Great job!!! Poignantly Pointing to the Point of Pointers without being Pointless. ;)
@N.A._McBee
3 жыл бұрын
I watched this once, and I'll watch this even twice or thrice or whatever it takes to thoroughly understand what's going on here. This is one of the best educative videos I've ever seen. I think it'll take me weeks of playing and experimenting with code to figure out the complexity of this stuff. Thank you very much!
@nekoill
4 жыл бұрын
Instantly liked after the definition of a pointer without a prompt. Also, I've been inexplicably drawn to C++ since I was a teenager, but couldn't quite start learning it, but now there's a huge KZitem library, so what better time to start learning.
@charles-y2z6c
5 жыл бұрын
I have not done C/C++ in 20 years. I miss it. Thanks fir the stroll down memory lane.
@thomasg5554
4 жыл бұрын
Well you'll still miss your C/C++ memories from 20 years ago when you start reading about C++11 and discover "smart" pointers.
@alexvanheerden5702
5 жыл бұрын
Thank GOD for C#. Though your demonstration of polymorphism is somehow better than any other I've seen in higher level languages like C# which is a huge credit to your manner of explanation.
@SCARRIOR
4 жыл бұрын
C# is such a lazy language
@alexvanheerden5702
4 жыл бұрын
@@SCARRIOR What you call lazy, I call Abstraction 😋
@xDR1TeK
4 жыл бұрын
How on earth did you hide for so long from me? Give me your brain. I know c++ since before the namespaces were invented. Intermediate level i hope. But somehow some basic stuff escape me. This video, hiding on youtube away from everyone's knowledge, is a crime.
@pro4skill
3 жыл бұрын
12:00-12:10 "The pointers work in a space defined by the type of object they are pointing to" - This was extremely helpful and concise
@flioink
5 жыл бұрын
"The name of the array is a pointer" which I remember from other lessons. When the "*" is used to request the value of some pointer variable is called "dereference" as far as I understood it. int a = 5; int* b = &a; cout
@reenamola2162
2 жыл бұрын
the word dereference isn't intuitive. "value of operator" makes far more sense
@breathermachine
5 жыл бұрын
An interesting thing to note is that there's really no external "pointer" pointing to an array when you declare one. From the programmer's point of view, the declaration only allocates (sizeof(type) * number of elements) bytes, nothing more. The compiler/linker just makes array access/pointer arithmetic easier by "assigning" to an array A the address of the first element.
@javidx9
5 жыл бұрын
A great point John
@breathermachine
5 жыл бұрын
@@javidx9 Haha, no pun intended! :)
@laureven
4 жыл бұрын
This is a perfect video about pointers. any other videos by somebody else are not necessary ...Just trying to write an original comment to point my point that I really enjoy watching Your videos to the point I even watched them when I have no clue about what they are and there is no point to watch them (a reference to the latest one, this is still black magic for me) ... Regards and Thank You
@DevranUenal
5 жыл бұрын
KZitem was on Auto Play mode and suddenly this video came up. I'm so happy that I didn't skip. This is by far the best introduction I've ever got into pointers. So far, no book was able to teach me what you did in a couple of minutes. And +1 for the Chrome joke :D Edit: I forgot to say thank you. So: Thank you!
@javidx9
5 жыл бұрын
lol, cheers Devran! :D
@Chemateur
5 жыл бұрын
I'm not sure if someone already pointed this out, but the reference at 29:40 is unnecessary. The reference would be needed if you were actually changing the pointer inside of the vector but the delete operator doesn't do that, it only changes the memory that's being pointed to by the pointer. Using: for (auto a : vSomeVector) delete a; would still work just fine, since it would create a copy of the pointer, and delete would still deallocate the memory location that's pointed to. You can double check that the pointer itself is unmodified by printing the value of each pointer in the vector before and after the delete. The address they hold should stay the same, even though the memory they point at becomes invalidated. Not really important, but figured I'd share anyway just in case someone was interested :) I love the video by the way.
@Sparkette
4 жыл бұрын
Just finished pointing this out myself. Glad I'm not the only one who noticed. :) Was surprised to hear him make such a critical error in his explanation, but I guess it happens to the best.
@lnagy88
5 жыл бұрын
I'm a C# developer and used C and C++ at the university. Modern C++ used with VS just fascinates me, please do more C++ videos and if you could do some compares with C# it would be very helpful. Thank you for the great video on pointers!
@bjbell52
2 жыл бұрын
I've always considered C# to be Borland's Delphi with a C syntax.
@josephmills1104
5 жыл бұрын
When you made that large section of memory in your picture for RAM I immediately thought you were going to say that it was fir chrome, and you did. Lol, thanks for that.
@hipwave
5 жыл бұрын
note, when casting to int the address of pointers to char (about 17:20 ) , compile will fail unless the flag -fpermissive is enabled.
@renatodex
3 жыл бұрын
That's true, I had the same problem. An alternative is to use `intptr_t` as cast.
@mevalia
3 жыл бұрын
Amazing video. But for those trying today 16:20 : Char* cannot be cast into integer on 64bits system. So don't do: (int) pLocation0 but (void*) pLocation0.
@TwstedTV
4 жыл бұрын
Im new to C++ about 2 to 3 months into C++ learning. Love the video but the second half of the video , I just wanted a rhino to just stomp on my head.....LOL I was confused as all hell LOL. Hopefully as I continue my course im doing in C++ this will come to light....LOL Hopefully by December 2020 I SHOULD have a good grasp of C++ :) I subscribed to your channel, because I love the way you teach..... because you don't have alarmingly loud music in the background and speaking a thousand miles per hour.....LOL thank you. - hopefully some time soon as I keep learning, the second half of this video will come to light for me :) PS> Im trying to find a full C++ course from you. Have you done any ? or plan to do some time soon ?
@romanromero473
3 жыл бұрын
Thank you for the informative videos. If I was trying to make a game like Megaman X which programming languages would be best suited?
@javidx9
3 жыл бұрын
Hmmm, at first I thought that was an easy question, but actually it isnt. The language is less relevant than the framework you want to use (which will imply the language you need anyway). For example, my framework (olcPixelGameEngine) does 2D pixel style games, but requires you know C++, Unity uses C#, Love2D uses Lua, PyGame uses Python. So really the question you should be asking yourself is do you want to learn a language, or just make the game? If the former, you cant go wrong with C++, if you can code in that you can code in anything. If the latter, Unity (or indeed GameMaker) feature lots of ready made tools you can drag and drop into place to make your product.
@Temulgeh
4 жыл бұрын
I just started c++ and without having seen the entire video, I already know this will be gold
@renomtv
3 жыл бұрын
so a pointer is like a desktop icon ... got it "&" is like saying the directory of the source file "*" is like double-clicking on the icon to bring out the source file
@grayaj23
3 жыл бұрын
Circa 1985-ish, I started down the path to a CS degree. It was probably called something like IS or MIS at the time. The school I was at structured this so that first-year programming courses were taught in Pascal. Second-year was in C. Of course, we didn't call it "K&R C" at the time, because the ANSI standard wasn't complete yet. I noticed during the C part of the program that in every class, there would inevitably be someone sitting in the front row who, sometime well past the first week or two of class, would suddenly ask "Wait. What's a pointer again?" Pascal had pointers -- oversimplified and of limited utility, but clearly pointy pointers used to point at things. How do you make it as far as an upper-division class in a discipline that critically requires a good understanding of pointiness and then ask "wait, what's a pointer?" This would bring the entire class to a screeching halt for a week while the Prof set about clearing up the confusion of a student who would inevitably take a W anyway. This happened in at least three different courses, and with a different person each time. And THAT, my friends, is why I bailed on software as a career and became a Certified Netware Administrator and embarked on a career in Ops, where our job is to make the product look like it works properly.
@berksteraydo9517
4 жыл бұрын
I was a freshman the previous spring semester, we had a C programming course. Now I'm looking into C++. Anyway, I should say that I feel disoriented by the fact that people encourage using smart pointers. The point is to handle the memory (and performance) better why would I give that away? Why c++? Just use python or something.
@javidx9
4 жыл бұрын
I tend to agree - smart pointers are useful however if you want to semantically follow the concept of object ownership. This is great for some situations, and a hindrance for others. The key thing is to use the right tool that gives you the easiest path to the solution you require.
@gondoravalon7540
3 жыл бұрын
Touched C++ for a while, then went to teaching myself C ... and all sorts of other stuff in between then and now, looking at all the new features and things in C++ is overwhelming AF
@merthyr1831
3 жыл бұрын
I managed to complete a programming test for a post-grad job with this refresher on ptrs! thank you
@finmat95
3 жыл бұрын
31:25 mindblowing part. In my university, professor gave us a programming exam that used pointers to vector cells. You're so clever.
@iwanwilaga
4 жыл бұрын
Hilarious start around 01:15 .. :D and now i continue my journey towards the 2nd minute. Best wishes! (update, i finished watching this episode, ultra-invaluable, perfectly crafted and articulated knowledge. As usual. Although i'm nobody in C++ yet, but surely got hyped and inspired by watching the Right materials on the web.. ^^ God bless you : )
@JamesStocks
5 жыл бұрын
Awesome video. Usually an explanation of pointers is just the first minute of this, and an assertion that they're really straightforward. Never usually go further and actually deal with how they can be confusing. Thank you!
@MrS9b
4 жыл бұрын
29:30 - Not really necessary. You're only iterating ptrs. Deleting a ptr will not affect the value stored in the ptr. However, it's good practise to also null the ptr, that's why you might want to iterate by reference. By iterating by value, the range based for is the equivalent of: for ( int i = 0; i < vSomeVector.size(); ++i ) { sSomeBaseObject* a = vSomeVector[i]; delete a; } which is perfectly fine. Also, in this context, & is not "address of". You're simply saying it's a reference type, in the same way * after a type name makes a pointer type.
@charlesmayberry2825
4 жыл бұрын
12:40 in, things that will catch an unaware programmer... in my best 6th sense voice "I see dead references"... also memory leaks. Now that I've watched the video I'm really glad you hit on both of those points. In fairness, Pointers were the hardest part of C++ for me to get my head around. I've found that smart pointers simplify some processes when doing engine programming that relies on entangled subsystems (game engines are BAD about that) Weak and strong pointers become handy at that point. It does not make up got GOOD habits, but it IS useful.
@JAkOBiUSs
4 жыл бұрын
I've just been debugging my code for hours. Then I remembered that a couple of months ago I learned something about how vectors and pointers don't always mix that well. Turns out I was doing the exact mistake at 30:50 :-P You're a life saver javidx9. I don't think I would've figured it out myself. For me, the natural follow up question now is: is there a "correct" way to point to a container element?
@javidx9
4 жыл бұрын
lol thanks. The correct way to point to a vector element is "dont". If you allocate it all beforehand and wont change it, its ok. That said, for containers like lists its ok.
@miko007
5 жыл бұрын
smart pointer are the way out of all our memory leaks. i can not understand, how you can propose to beginners not to use them. we have a policy here at our university, than no c++ program should ever contain the "new" keyword (nor malloc, duh) again. and thats for good.
@javidx9
5 жыл бұрын
I've never advocated not using them, just to try and understand what they do, which is ultimately wrap a raw pointer. Not leaving this knowledge out is equally important.
@miko007
5 жыл бұрын
javidx9 then i am sorry. i think that did not translate very well over video. it seemed like you were proposing something like "ah, yeah, there is also some newfangled stuff called 'smart pointers' but i really do not think you should use them".
@tinym00n
5 жыл бұрын
congratulations, you have successfully hacked my brain!
@kaloyanvylchev3818
5 жыл бұрын
Vector memory allocation was amazing, makes so much sense! Thanks for taking your time to explain it in such depth!
@antongorobets9146
3 жыл бұрын
Great video. Thanks for the vector drawings in RAM! very clearly
@fenril6685
2 жыл бұрын
This is one of the absolute best videos on the internet regarding pointer fundamentals. I recommend this to people who are new to the language any time I see them struggling to really grasp what pointers are and how they work. One thing I do wish you had gone over in this video (and would perhaps be a good topic for a supplementary video) is the differences between taking parameters by value, by reference, by pointer, by pointer to pointer, and by reference to pointer which I find to be the most common 4 ways to pass values into functions. For instance, when you start needing to develop application layers that are doing low level operations (like pointer arithmetic on a byte buffer), it can be very easy to make mistakes like not realizing that you need to either return a modified pointer from the function so that you can use the updated memory address externally or take a reference or pointer to a pointer as the parameter type. Also, I like your bit about smart pointers at the end, however, I think a good rule of thumb is that smart pointers are useful when they are being used how they were intended to be used, which is to denote ownership and not just "because it's modern". In otherwords if this is a low level piece of code that needs to be closely managed and optimized, like designing a custom data structure like an Octree implementation, then it is not a good idea to use smart pointers. If however, you are working on systems within an API where you need to denote "has-a" relationship component ownership of difference objects, then having unique and shared pointers can be useful and appropriate there.
@manuelengel3680
4 жыл бұрын
I love how "german" you say the word debugger. Greetings from Germany! :)
@FrankenLab
3 жыл бұрын
de-booger... kind of like picking your nose, lol.
@asifzamanpls
3 жыл бұрын
Nicely explained! Definitely one of the best programming channels on KZitem that actually explains things in-depth.
@2k7u
2 жыл бұрын
This vid helped me get back on track, thanks lol
@johanavalos3283
3 жыл бұрын
How did the KZitem algorithm know that i needed to know this? I was about to look it up and it showed in the recommended section lol
@M4RC90
3 жыл бұрын
There is a good reason not to declare pointers like this: int* a; Example: What types are these two variables: int* a, b; ? Write it like this and it becomes more clear: int *a, *b; But as with everything, this is just personal preference.
@javidx9
3 жыл бұрын
Yes and no, I guess I fundamentally agree with you, but anyone that's programmed in C or C++ for more than week can cope with understanding the clumsy syntax for their pointer declarations.
@georgebradley4583
3 жыл бұрын
Note to myself: What I’ve learned from this video. Pointers are variables that hold memory addresses. You need to specify what datatype the pointer points to. A pointer of int can’t point to a double. A pointer of int can point to a memory address that stores an int value. Pointers are used in polymorphism to point from a base class to a derived class and have different types of objects (which all have one thing in common, they’re derived from the base class) this means it’s valid for an array or a vector to store both the base class object and derived class object in the same container and treats them as all the same. Thanks so much!
@SCARRIOR
4 жыл бұрын
Can you do that C++ playlist now like you promised? You said there were a ton of resources already available and what you say is completely true, but what you fail to understand is that these people are advertisement hoarding inefficient introduction times and horrible accents with the whole persona “ look at me, you learn from me i am better i am master” which is very irritable. Would rather learn from someone as wholesome as you mate
@javidx9
4 жыл бұрын
Well thank you Scarrior for the complement. It keeps popping up as a popular request to do a C++ fundamentals series. It is something I have started drafting, but I want to release it in a sensible way - i.e. all at once, because no one wants to wait in between sections. That however is enormously time consuming, and Id effectively have to go dark for a few months. Its on the cards, but I cant say when :(
@cruelplatypus67
4 жыл бұрын
So I learned c++ in school and college and didn't know what & and * was all about, thanks for the in-depth explanation. Thank you so much.
@upyours2707
5 жыл бұрын
I just found your channel a couple of days ago and already subbed and bingewatched a good chunk of them. Very informative and I learned lots of things. Thank you for sharing your knowledge.
@fundamxd
4 жыл бұрын
Hi David, I've just started watching your videos these last days and they are just fantastic and so helpful and I really love the way how you explain things and teach them. As a beginner, I really want you to mak. A series of full courses about C++ to teach us the fundamentals and the basics and also the advanced stuffs about C++ that will really help us and motivate us to learn more and more and it will also help you too as this channel owner. So much respect to you sir, Thanks.
@davidbailey1777
5 жыл бұрын
Great video! I’ve almost no programming exp and I could still mostly follow this. The sketches were a critical part of making this work. Well done!
@aliabadi6049
4 жыл бұрын
1:17 LMAO Seriously, great content!
@adsick_ua
4 жыл бұрын
Rust programmers be like: lol.
@Ureallydontknow
4 жыл бұрын
not exactly. both C++ and rust give you the option to be garbage collected automatically or manually. this is better than choosing a language based on if(garbage_collected). you instead decide what you want when you write the code. garbage_collected=True, garbage_collected=False. you have control over that without switching languages to solve a problem. you can think of it like a more powerful language that is a hybrid of languages mixed in the same application. best of both worlds.
@ZooperPlayz
4 жыл бұрын
My education was a scam. I really mean it.
@pxolqopt3597
3 жыл бұрын
Teachers teach causs they get paid, this guy teaches cause its his passion
@rdius4822
3 жыл бұрын
@@pxolqopt3597 That's true, but not for all teachers. Teachers do exist who are passionate about their job and are just like him :D
@GreedyLane
6 жыл бұрын
Great video. I wish you'd explained difference between reference and pointer as well, can't really understand it.
@javidx9
6 жыл бұрын
Hi Asterix - fair enough, a quick One Lone Coder lesson. The difference between pointers and references is - nothing! As I elude to at the start of the video, the syntax is not helpful here as they use the same symbols with multiple purposes. I assume you are referring to functions along the lines of SomeFunction(SomeObject &o). The ampersand '&' can always be read as "get the address of" so in this case we pass a pointer to the object as the argument to the function, instead of a copy of the object itself. This means any changes the function makes to the object, it makes to the original object. You could interpret this as the function having both read and write access to the original object, whereas without the ampersand it would only have read access (as writing would only affect the copy). The reason you may want to pass by reference could also be performance. Instead of having to copy the object (which may not be trivial), you just copy its pointer. In C++ you have to explicitly say you wish to "pass by reference" and it assumes "pass by value" is the default. Java on the other hand almost does everything as "pass by reference".
@SFreakHD
4 жыл бұрын
@Seamus O'Dork because?
@Skiskiski
4 жыл бұрын
Question: I do assign &var (7) to a *voidptr (void pointer). I do cast the void pointer to int pointer. Afterwards, I do print out *voidptr (gives me address of the variable) and **voidptr (gives me value of the variable). Why does not *voidptr dereference give me the value (7), but the address?
@Levelworm
5 жыл бұрын
Good tutorial, and I like the gotcha about using pointers to vector elements. Do you plan to do some videos about smart pointers too? I'm especially interested to see how to interact C libraries (e.g. SDL2, MFC) with smart pointers. **Edit** actually just finished listening to your video so I figured you probably won't do a video for smart pointers :D
@lijstthuispiano
3 жыл бұрын
Thank you for the explanation. I’m thankful for Python though. I’m afraid my brain is not big enough fpr C++😑
@iwir3d
4 жыл бұрын
Okay saw the console game engine, and the pixel engine, and now this. I hit subscribe, and I am not disappointed at all. Keep up the great work!
@NoSpeechForTheDumb
Ай бұрын
This is about pointers in C, which are eventually included in C++ for backwards compatibility. Actual C++ pointers look like "std::unique_ptr" and are much "smarter".
@ArturKorobeynyk
6 жыл бұрын
Absolute GEM! It is not only easy explanation to general pointers but also to virtual functions and memory allocations and smart pointers which are rarely touched by any topic named C++ pointers. Thumb Up-ed, subscribed and shared.
@javidx9
6 жыл бұрын
Hi Artur, I really appreciate that, thanks a lot!
@adempenver9416
6 жыл бұрын
excellent explanation, definitely cleared up a couple of things I misunderstood about the language.
@javidx9
6 жыл бұрын
That's great to hear Adem, I tried with this video to show lots of other "interesting" things to put pointers in a broader perspective, so I'm pleased it helped.
@josiahmartin6463
2 жыл бұрын
This video is awesome 👌 I've been struggling with pointers for awhile and you explain the concepts clearly and throughly
@pharazon5865
3 жыл бұрын
thank you very much for this kind of detailed video, was super helpful and easy to follow. I'm new in C++ and it helped me a lot
@jakobfredriksson2272
3 жыл бұрын
I thank you so much for this javidx9. I don't know why something that's not really complicated for some reason is, or was for me. I'm learning to code "in reverse"; went from an interpreter language backwards and now learning C and lol, I hadn't even heard of "pointers" before this endeavor =)
@VEGETADTX
Жыл бұрын
The fact that there are millions of people who find the concept of pointers difficult to understand or to apply in practice and yet feel totally comfortable using the BLOODY MESS that is CSS, will always be beyond me :) No offense CSS folks, it's just my experience with CSS....
@starinsky2873
6 жыл бұрын
I cannot code in binary or machine language so I choose c++ if I cannot learn c++ I am retarted for sure 😂😂😂
@javidx9
6 жыл бұрын
C++ is one of the more challenging languages I suppose, I'm sure you'll manage it.
@uuu12343
6 жыл бұрын
Holy heck javid, i never fully understood pointers for the longest time doing c++, i now have a reference guide for pointers fundamentals...and actually understanding the darn things
@javidx9
6 жыл бұрын
That's great to hear Eternia, thanks!
@starinsky2873
6 жыл бұрын
recommend you to make a box like this name value adderss and then explain
@GPTDavid
4 жыл бұрын
I will replay this video as many times as it takes for me to grasp the idea of pointers. i'm not kidding.
@williamwambua7710
3 жыл бұрын
You lost me when you introduced pointers of pointers...omagaaddd
@orbyfied
3 жыл бұрын
Great video! But arent local variables like A in your example allocated on the stack?
@pXxDisasteRxXq
4 жыл бұрын
seems to me that for have a good understanding of pointers you should also explain the difference among stack and heap, and what means declare and access in one rather than the other.
@ZeHoSmusician
4 жыл бұрын
_What are pointers?_ You know--directions, advice... XD Sorry, deriving from a joke by #XKCD: xkcd.com/138/
@gcm4312
3 жыл бұрын
34:50 is it OK to have a pointer to an element of an array, though? I'm thinking of C here. Say I have a struct `CPU` that has an array `unsigned char memory[1024]` in it. Is it ok to have a pointer to a part of that memory array (eg `unsigned char *RAM_START = &CPU->memory[200]`)?
@RussellTeapot
2 жыл бұрын
12:05 I tried the code, and got the error "cast from 'int*' to 'int' loses precision" and I couldn't figure out why. Then I realized I was working on a 64 bits system, so the size of the memory addresses (and thus the pointers size) is 8 bytes: I fixed it by casting the pointers to 'long' instead, which is 8 bytes.
@pablom2274
2 жыл бұрын
Thanks i didn't know that, i got the same error and used long but i didn't know it was because of my 64bit system.
@RussellTeapot
2 жыл бұрын
@@pablom2274 Well, I'm not exactly sure that is the case, but it seems the most logical reason I can come up with
@HammerheadHal
5 жыл бұрын
It's a bit harsh not using the `auto` keyword while calling smart pointer initialisation "wordy": Olde wilde weste/Rust's raison d'être/oigerroffmoilawn: sImportantObject* pImportantObject = new sImportantObject("leak"); delete pImportantObject; // leak averted, or crash Fitter, happier, more productive: auto spImportantObject{ std::make_unique("safe") };
@dwivedys
4 ай бұрын
This is simply next-level amazing and it’s from 5 years ago! Wonder where you are David!?
@Cyberfoxxy
4 жыл бұрын
I think the biggest problems with C++ pointers is the syntax. It's a little misleading that the * symbol is used for both "pointer types" and as a dereferencing operator (and multiplication). E.g "int * p = (int*)*x*(byte*)(&y+2)" A better syntax would be object syntax template class Pointer{ T GetValue(); void SetValue(T v); int GetAddress(); void SetAddress(int v); } But i'm just a c# noob, so what do i know.
@lonec1777
4 жыл бұрын
I see why my fellow programmers keep recommending me to use shared pointers. I dont think Im going to use them anyway.
@TheRealJman87
4 жыл бұрын
I too avoid shared_ptr as much as possible. I do use unique_ptr quite a lot, though (actually, a custom version of it I made myself that tends to compile a bit faster, since it does not require or any other STL headers).
@lonec1777
4 жыл бұрын
@@TheRealJman87 yeah another thing I do is try to stay away from most std functions like max, min, remove_if, and all those default stuff for two reasons: I really really don't want to call functions that constantly call other functions inside them (i looked at some of the source code for different compilers), the annoying useless typedefs they always have associated with them, and they also look very ugly and don't look my convention. A lot of them also look fairly pointless too, like iterator. I find a regular for loop looks nicer and makes more sense, but modern C++ has been trying to shove that down our throats lately, as well as smart pointers too. I try to code as C-like as possible until i need the use of classes.
@bumbarabun
4 жыл бұрын
@@lonec1777 unfortunately you just do not understand how C++ especially meta-prorgamming part works. And you are missing huge and probably most important part of C++.
Пікірлер: 779