What Are Pointers? (C++)

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 776

  • @Ureallydontknow
    @Ureallydontknow 4 роки тому +237

    "basic use of pointers"

  • @starpjor
    @starpjor 6 років тому +1248

    David, you should have "in depth c++" series created. Keeping such precious knowledge to yourself is a crime :D

    • @javidx9
      @javidx9  6 років тому +436

      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
      @TahirGluttony 5 років тому +17

      @@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
      @edwin3928ohd 5 років тому +7

      @@javidx9 it's been a year! i would love a series like this

    • @maycodes
      @maycodes 4 роки тому +5

      @@javidx9 please consider it or Can you share resources ?

    • @DannyOvox3
      @DannyOvox3 4 роки тому +5

      javidx9 please do it, I will be starting a course in it but your UA-cam videos will be a life saver I’m sure

  • @joshlovesfood
    @joshlovesfood 3 роки тому +44

    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

  • @pro4skill
    @pro4skill 4 роки тому +6

    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

  • @kamilbizon8317
    @kamilbizon8317 6 років тому +35

    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
      @javidx9  6 років тому +11

      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.

  • @stackercoding2054
    @stackercoding2054 3 роки тому +34

    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
      @MikeMcRoberts 2 роки тому +4

      Same here. Exact same point in the video I got lost.

    • @NN-uy6ik
      @NN-uy6ik Рік тому +1

      Same 😂

    • @jonnymcgrath4816
      @jonnymcgrath4816 Рік тому

      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
      @jonnymcgrath4816 Рік тому

      @@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
      @barathkumar6903 8 місяців тому

      @@MikeMcRoberts R u Zoro?

  • @_rcs
    @_rcs 6 років тому +425

    This channel is such a gem, thank you Javidx9.

    • @javidx9
      @javidx9  6 років тому +34

      Hey no problem Rory, thanks!

  • @YoomarTuNoOmar
    @YoomarTuNoOmar 5 років тому +218

    "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
      @mehmetakyuz5290 5 років тому +7

      rofl tru dat

    • @harrymack3565
      @harrymack3565 4 роки тому +32

      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
      @Mateus.007 4 роки тому +14

      int *(*f(void (*)(void *))(void *);

    • @xrafter
      @xrafter 4 роки тому +5

      @@Mateus.007
      This is bad and hard to read i hope no one use it.

    • @Mateus.007
      @Mateus.007 4 роки тому +10

      @@xrafter In the C standart library there's a function like this:
      void (*signal(int, void (*)(int)))(int);

  • @JamesStocks
    @JamesStocks 5 років тому +3

    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!

  • @N.A._McBee
    @N.A._McBee 3 роки тому +13

    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!

  • @fenril6685
    @fenril6685 2 роки тому +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.

  • @nekoill
    @nekoill 4 роки тому +7

    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 UA-cam library, so what better time to start learning.

  • @Temulgeh
    @Temulgeh 5 років тому +20

    I just started c++ and without having seen the entire video, I already know this will be gold

  • @finmat95
    @finmat95 3 роки тому +3

    31:25 mindblowing part. In my university, professor gave us a programming exam that used pointers to vector cells. You're so clever.

  • @charles-y2z6c
    @charles-y2z6c 5 років тому +25

    I have not done C/C++ in 20 years. I miss it. Thanks fir the stroll down memory lane.

    • @thomasg5554
      @thomasg5554 4 роки тому +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.

  • @nahbruhwhat
    @nahbruhwhat 4 роки тому +9

    Excellent! This is as calming as watching a documentary about lions on the savanna!

  • @merthyr1831
    @merthyr1831 3 роки тому +3

    I managed to complete a programming test for a post-grad job with this refresher on ptrs! thank you

  • @georgebradley4583
    @georgebradley4583 4 роки тому +2

    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!

  • @cruelplatypus67
    @cruelplatypus67 4 роки тому +1

    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.

  • @asifzamanpls
    @asifzamanpls 4 роки тому +3

    Nicely explained! Definitely one of the best programming channels on UA-cam that actually explains things in-depth.

  • @kaloyanvylchev3818
    @kaloyanvylchev3818 5 років тому +5

    Vector memory allocation was amazing, makes so much sense! Thanks for taking your time to explain it in such depth!

  • @flioink
    @flioink 5 років тому +8

    "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
      @reenamola2162 2 роки тому

      the word dereference isn't intuitive. "value of operator" makes far more sense

  • @DevranUenal
    @DevranUenal 5 років тому +5

    UA-cam 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
      @javidx9  5 років тому +2

      lol, cheers Devran! :D

  • @AdamMohamed-cq9fv
    @AdamMohamed-cq9fv 3 роки тому

    in 40 minutes you cleared up what my professor couldn't explain in 3 hours, thank you

  • @milkjs
    @milkjs 3 роки тому +66

    You're teaching this for free when I pay thousands for a shitty explanation in school.
    God bless.

    • @Ironlionm4n
      @Ironlionm4n 3 роки тому +1

      Oof this one hit hard today

  • @Chemateur
    @Chemateur 5 років тому +17

    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
      @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.

  • @alexvanheerden5702
    @alexvanheerden5702 5 років тому +11

    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
      @SCARRIOR 4 роки тому

      C# is such a lazy language

    • @alexvanheerden5702
      @alexvanheerden5702 4 роки тому +4

      @@SCARRIOR What you call lazy, I call Abstraction 😋

  • @tahwnikcufos
    @tahwnikcufos 6 років тому +262

    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
      @javidx9  6 років тому +66

      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
      @valizeth4073 5 років тому +11

      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
      @samdavepollard 4 роки тому

      @@rockapartie looks like a book i'll find useful - thanks for mentioning it

    • @joestevenson5568
      @joestevenson5568 3 роки тому +1

      @@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
      @framepointer 3 роки тому

      @@joestevenson5568 C also does not have passing by reference.

  • @charlesmayberry2825
    @charlesmayberry2825 4 роки тому +1

    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.

  • @lnagy88
    @lnagy88 5 років тому +9

    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
      @bjbell52 2 роки тому

      I've always considered C# to be Borland's Delphi with a C syntax.

  • @josephmills1104
    @josephmills1104 5 років тому +6

    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.

  • @ArturKorobeynyk
    @ArturKorobeynyk 6 років тому +2

    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
      @javidx9  6 років тому

      Hi Artur, I really appreciate that, thanks a lot!

  • @TheNormalUniverse
    @TheNormalUniverse 4 роки тому +11

    Lol I love the “what are pointers” Art!

  • @godsstepson1495
    @godsstepson1495 2 роки тому

    About to go back to college and I basically know nothing pertaining to C++ but watching this is getting me excited and wanting to understand more.. I'll be coming back to watch these in the future once I understand the language and can pick up on everything your teaching.. thank you, this is what I needed to remember if I still had the drive to learn like I did in my younger days.

  • @uuu12343
    @uuu12343 6 років тому +2

    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
      @javidx9  6 років тому

      That's great to hear Eternia, thanks!

  • @GPTDavid
    @GPTDavid 5 років тому +1

    I will replay this video as many times as it takes for me to grasp the idea of pointers.
    i'm not kidding.

  • @SumoCumLoudly
    @SumoCumLoudly 5 років тому

    I already know pointers but have to say I like your way of teaching, very polished, succinct and thorough. I like how you don't assume too much knowledge and quickly explain or elaborate things that some people might not know.

  • @burntt999
    @burntt999 3 роки тому +1

    Hola Javid, thank you for all these great free lessons. Back here rewatching this because I ran into the smart pointers in the breakout PGE tutorial wiki and it threw me way way off then I remembered you had a pointer video. Thankfully! You’re incredible for making all these educational videos and making them free. I would be way behind where I am now in my programming journey if you never started this channel. I am incredibly thankful for all your work..
    thank you, thank you, thank you.

    • @javidx9
      @javidx9  3 роки тому +1

      Thanks for your kind words Lee, it's always pleasing to hear when someone has found the videos useful, and it keeps me motivated to keep going - which I will in the new year!

  • @RozzmanLists
    @RozzmanLists 5 років тому +1

    Even though I haven't progressed to using C or C++ yet, but learn some basics about programming using mainly Lua and Python, I found this video - and many others from you too - VERY useful. Your clear and organised style of explaining is a joy and it is very easy to follow you. Your dry sense of humor adds to the fun. Thanks for your efforts, javidx9

    • @javidx9
      @javidx9  5 років тому

      Hey no problem and thanks Rozzman!

  • @AlexSmith-fs6ro
    @AlexSmith-fs6ro 5 років тому +8

    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.

  • @imrank340
    @imrank340 Рік тому

    Undoubtly perfect "Englishman" made a C++ Pointer subject made easy and eloquently explained its inner working, briskly introducing smart pointer. Good (imaculate) work David.

  • @davidbailey1777
    @davidbailey1777 5 років тому +3

    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!

  • @NoSpeechForTheDumb
    @NoSpeechForTheDumb 3 місяці тому

    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".

  • @fisher00769
    @fisher00769 4 місяці тому

    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
      @javidx9  4 місяці тому

      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!

  • @fundamxd
    @fundamxd 4 роки тому +2

    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.

  • @rockyrivermushrooms529
    @rockyrivermushrooms529 6 років тому +6

    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
      @javidx9  6 років тому +3

      Its all about the practice, videos, guides and tutorials will only get you so far, at some point YOU need to write the code.

  • @johnwoolley2198
    @johnwoolley2198 4 роки тому

    I've seen a lot of material trying to introduce pointers and I have to say I think yours is the best and most intuitive of them all, and it's free!

  • @laureven
    @laureven 4 роки тому +1

    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

  • @alchavez2616
    @alchavez2616 4 роки тому

    Haven't programmed in C/C++ in a while. This brings the joy back

  • @TomJez100
    @TomJez100 5 років тому +9

    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. ;)

  • @wellalrightythen5941
    @wellalrightythen5941 4 роки тому

    wow, thank you. All i gada say. I don't know why i decided to jump in and take on c/c++ as the first languages i learn, should have started with python. (I ended up learning python just as a result of getting frustrate with c++, started dipping into it and right away just seeing how simple it is in comparison and how the language it self clearly states the intent of the code, I ended up taking a break all together from c ++) Your videos though make it really easy for me to understand the things i was struggling with so I'm back on it now. Blows my mind how much information is out there and in so many formats. I can go through 10 videos some times and still not understand something and then finally find someone that just explains it in a way, in full detail very clearly so i can grasp it. What ever some of you guys are making in add revenue, isn't enough for the value in the content your putting out, that's for sure.

  • @DassVeryGood
    @DassVeryGood 2 роки тому

    I might be learning on my own, but this is single handedly the best video on pointers! might be just the basics, but its an actual comprehensive explanation of those basics that make it understandable. Thank you so much for your help, LEGEND

  • @iwanwilaga
    @iwanwilaga 4 роки тому +2

    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 : )

  • @upyours2707
    @upyours2707 5 років тому +2

    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.

  • @dudaseifert
    @dudaseifert 4 роки тому

    Didn't think i'd learn new things about pointers after programming in C for 8 years. color me surprised!

  • @hipwave
    @hipwave 5 років тому +8

    note, when casting to int the address of pointers to char (about 17:20 ) , compile will fail unless the flag -fpermissive is enabled.

    • @renatodex
      @renatodex 4 роки тому

      That's true, I had the same problem. An alternative is to use `intptr_t` as cast.

  • @mevalia
    @mevalia 4 роки тому +1

    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.

  • @damianc8738
    @damianc8738 3 роки тому

    Oh man, i've spent nearly 5 hours on a video, which is about 45 minutes long. From one video, i went on few other videos about pointers, even guys who were doing map and pictures from the pointers but still, this one was the best. Thanks man! And i have to go sleep cuz i need to wake up early..

  • @womisuVv
    @womisuVv 4 роки тому

    One of the best videos! A Pointer is just a variable that holds a memory address.!!

  • @rdoetjes
    @rdoetjes 3 роки тому

    I have had many interns who don’t understand the concept of pointers. And initially I didn’t understand because it so fundamental to CS. Then I found out that college students don’t get a semester of assembler programming anymore. And then it fell into place. So initially I took an hour to bring them up to scratch. And during those sessions I noticed that the * is very confusing to them in C (C++) as it basically means two different things. As an assignment and an operator for dereferencing aka getting the value from that address the pointer is pointing to. Then all of them understood.
    But I still am amazed how you can get through 4 years of college in Computer science and not fully understand the fundamentals of a computer.

  • @pharazon5865
    @pharazon5865 4 роки тому +1

    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

  • @markonikolic1386
    @markonikolic1386 4 роки тому

    Awesome channel! We were learning OOP this year at uni and the subject of pointers was confusing for most. It is a shame this video found me only now, but I will surely go back to it whenever I want to make sure that I am using pointers correctly and cleaning after myself. Pointers get confusing when I start using arrays of pointers and matrices of pointers which are required in the exercises we get. THANK YOU SO MUCH! Keep up the good work!

  • @adempenver9416
    @adempenver9416 6 років тому +3

    excellent explanation, definitely cleared up a couple of things I misunderstood about the language.

    • @javidx9
      @javidx9  6 років тому +2

      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
    @josiahmartin6463 3 роки тому +1

    This video is awesome 👌
    I've been struggling with pointers for awhile and you explain the concepts clearly and throughly

  • @汉房投资
    @汉房投资 3 роки тому

    very informative, and helped me greatly to understand and more importantly less fearful of use of pointers

  • @luketanner6373
    @luketanner6373 4 роки тому +1

    I really appreciate your delivery and concise examples and descriptions. Keep it up! :D

  • @marmoripelaao9830
    @marmoripelaao9830 6 років тому +3

    6 minutes in and I feel like a professional already!

    • @javidx9
      @javidx9  6 років тому

      Hi Marmori, Don't rush these things :D

  • @iwir3d
    @iwir3d 4 роки тому +1

    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!

  • @LaJola
    @LaJola 6 років тому +4

    This was the first thing we learned in my data structures class. Thanks for the video! Enjoying it.

    • @javidx9
      @javidx9  6 років тому +1

      Hi LaJola, yeah effective data structure management would be impossible without pointers

    • @RussTeeTrombone
      @RussTeeTrombone 6 років тому

      I’m in a DS course right now and I’ve found the previous and current explanations for pointers inadequate, and most books haven’t explained it in a satisfactory manner. This video has been an immense help.

  • @akashverma4280
    @akashverma4280 4 роки тому +108

    32:05
    Chrome: Got some RAM?
    OS : Actually ther...
    Chrome : Thanks!

    • @Leonhart_93
      @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
      @akashverma4280 4 роки тому +6

      @@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
      @Leonhart_93 4 роки тому +1

      @@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
      @akashverma4280 4 роки тому +3

      @@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
      @gondoravalon7540 4 роки тому +3

      @@Leonhart_93 "That is too little imo. "
      Too little? What do you mean?

  • @mannhansen9337
    @mannhansen9337 4 роки тому

    Thanks. This is the best pointer tutorial I have ever seen. You made pointers understandable.

  • @johanavalos3283
    @johanavalos3283 3 роки тому +1

    How did the UA-cam algorithm know that i needed to know this? I was about to look it up and it showed in the recommended section lol

  • @jakobfredriksson2272
    @jakobfredriksson2272 3 роки тому +1

    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 =)

  • @subliminalcastillo2126
    @subliminalcastillo2126 4 роки тому +3

    Man. In just one night of watching your videos, so many of my questions have been answered.

    • @javidx9
      @javidx9  4 роки тому +1

      Well i am pleased you are finding them useful Chris, and the feedback is much appreciated!

  • @Ochenter
    @Ochenter 3 роки тому +1

    Really clear and understandable, David.
    Nice video as always.
    Merry Christmas.

    • @javidx9
      @javidx9  3 роки тому

      Merry Christmas Daniel!

  • @Bolpat
    @Bolpat 4 роки тому +77

    Every time you say "Asterix" for asterisk, I cannot stop myself thinking: Why don't we call "&" the Obelix operator?

    • @inigo8740
      @inigo8740 4 роки тому +13

      One is rather small, the other one is round and large. Seems very fitting.

    • @ng4logic
      @ng4logic 4 роки тому +5

      That is genius. People should adopt this. Its very easy to remember and it makes sens

    • @achtsekundenfurz7876
      @achtsekundenfurz7876 4 роки тому +4

      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
      @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
      @achtsekundenfurz7876 3 роки тому +3

      @@tonyfremont Tbf, "parenthesis" sounds like an ugly medical condition, so I can understand why few people use that word...

  • @antongorobets9146
    @antongorobets9146 3 роки тому +1

    Great video. Thanks for the vector drawings in RAM! very clearly

  • @breathermachine
    @breathermachine 5 років тому +7

    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
      @javidx9  5 років тому +1

      A great point John

    • @breathermachine
      @breathermachine 5 років тому

      @@javidx9 Haha, no pun intended! :)

  • @nathanalgren288
    @nathanalgren288 3 роки тому

    Pointers! The unique selling point of C and C++, and also the most abused (knowingly sometimes and sometimes not)!
    This is not my first taste of pointers, but like the intro, I have deviated from the 'formal' terminology ('reference' and 'dereference') and, in the context of pointers, rechristened (in my mind) the & operator as the 'address-of' operator and the * as the 'value-of' operator.
    N.B. Due to the lack of quality material on it, I would appreciate a 'Modern C++ gems' series someday :)

  • @dirtyblasion15
    @dirtyblasion15 6 років тому +1

    I can answer it better than you in 3 words:
    They are a tresure.
    These cute little things saved me a lot in the past

    • @javidx9
      @javidx9  6 років тому

      Hey Dirty, Pointers are indeed tiny powerful programming weapons :D

  • @bredmond812
    @bredmond812 5 років тому

    I prayed for an in depth video on pointers in C++.

  • @tehf00n
    @tehf00n 5 років тому +4

    I clicked because I wondered how this concept could take a 42 minute video. It's always been a confusing thing to new people, but it's so simple. Im not being elitist, it's just there seems to mostly be an issue of when to use a pointer or a reference, and how other coders use language to relate. Sometimes you hear coders give examples where they say "you get a pointer to the object" when they mean a reference and vice versa. I was guilty of it myself, until I started to force it. I usually tell people that the difference between a pointer and a reference is like the difference of a .EXE versus a shortcut to that exe. A reference is the exe, a shortcut is the pointer. Its probably not the most informative analogy for it, but its all about knowing enough for now to get today's work done. Then relating it in future.

  • @methodinsane
    @methodinsane 4 роки тому +1

    Just found your channel. Exceptional tutorials, thank you so much for this stuff. I learn some c/c++ years ago but just find these explaining these concepts. Cheers!

  • @grayaj23
    @grayaj23 3 роки тому +1

    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.

  • @adrianj9695
    @adrianj9695 5 років тому +1

    Again. Thank you!!! I will now feel comfortable taking this class.

  • @miloradowicz
    @miloradowicz 3 роки тому

    I don't know if it's gonna be of use to anyone, but I personally prefer to think of declaration like
    T *t_ptr;
    as of an equation. It means if you dereference t_ptr, you'll get something of type T, and therefore t_ptr itself must be of type pointer to T. It facilitates understanding more complex cases like function pointers or arrays of pointers easier. Just remember that function call () and indexing [] operators have higher priority, and thus are executed first, unless you change the order with parentheses. For example, you can read the declaration
    T *f();
    as follows: if you call f and dereference the result, you'll get T, therefore f is a function that returns a pointer to T. On the other hand, the declaration
    T (*f)();
    means if you dereference f and call it, you'll get T, therefore f is a pointer to a function that takes nothing and returns T.

  • @anastasiak8589
    @anastasiak8589 3 роки тому

    Fantastic approach to presenting complicated information. Great video

  • @Wrtvrxgvcf55
    @Wrtvrxgvcf55 6 років тому +2

    mate, i cant tell you how many times your videos have helped me out. thanks!

    • @javidx9
      @javidx9  6 років тому +1

      Hey no problem buddy, good to hear.

  • @TheMedia325
    @TheMedia325 6 років тому +1

    Super helpful video, all the concepts are very thoroughly explained, really appreciate uploading of these videos.

    • @javidx9
      @javidx9  6 років тому

      Hi Idaisa, cheers!

  • @AngelTaylorgang809
    @AngelTaylorgang809 5 років тому +1

    Wow this video is freaking awesome, this man was born to teach. Subscribed

  • @napalmpig3772
    @napalmpig3772 5 років тому +2

    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
      @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.

  • @veto_5762
    @veto_5762 3 роки тому

    i'm feel proud of easily understand this video after a year of learn cpp by myself

  • @SuboptimalEng
    @SuboptimalEng 5 років тому

    Man, I wish I had this video when I was taking Computer Architecture and Systems Programming in college.

  • @rezafathi4367
    @rezafathi4367 3 роки тому

    The best explanation on pointers ever! I really hope you would create more c++ videos🤘

  • @silentsands
    @silentsands 5 років тому

    I musst admit, seeing this video from someone who actually knows what he talks about is a releaf. It helped me allot more than "Look and than we can do this and it makes this" without the "when we do this it does this and makes this"

  • @maycodes
    @maycodes 4 роки тому

    This was so ENLIGHTENING ! , Really I was confused just because of what you pointed out, Using * to declare and to to get value of.. Thank you so much.🙏🙏

  • @botobeni
    @botobeni 4 роки тому +1

    ur a legend man, best C++ channel on youtube

  • @jcesarzp
    @jcesarzp 4 роки тому

    I think a lot of people have trouble with pointers because of the way it is declared.
    In other words, these two forms are considered approved:
    a) int* ptrExample = & someVariable;
    b) int *ptrExample = & someVariable;
    In form a), you can visually understand that the pointer variable is only ptrExample, because "nothing touches it", it's a variable like others. However, in form b) visually, the programmer can understand that the pointer variable created is *ptrExample, including the asterisk.
    [1] I think that is why confusion occurs when dereferencing the pointer and getting the value it's pointing to. Because you must apply the dereference operator (*), when you initially thought that your variable already contained it.
    [1] I think this is one of the reasons, maybe the main one, obviously not the only one.

  • @tmcowley
    @tmcowley 4 роки тому +1

    you have a clear talent for teaching, thanks so much for this

  • @DominicVictoria
    @DominicVictoria 5 років тому

    The