C++ this Pointer

Sdílet
Vložit
  • čas přidán 13. 09. 2024
  • Jamie King showing how "this" in C++ is just a pointer to the current instance.

Komentáře • 48

  • @vandorlokronika9581
    @vandorlokronika9581 Před 11 měsíci +3

    11 years old but still great! Thank you for uploaded, finally I have understand! (from 2023 )

  • @Stoicsnowadays
    @Stoicsnowadays Před 3 měsíci

    An absolute masterpiece. I'm currently in Uni and "this" pointer was a strugle for me. Thanks a lot mate, wish you the best!

  • @JamieKingCS
    @JamieKingCS  Před 11 lety +3

    And...I finally figured out how to post the videos as responses to this video, so you will see the links to them on this page as well.

  • @MinhLe-xk5rm
    @MinhLe-xk5rm Před 7 lety +7

    Thank you sir! You make it all so clear with your example, really help with the convoluted C++ book I'm learning from.

  • @adnanmunawar7972
    @adnanmunawar7972 Před 11 lety +3

    Wonderful tutorial. Thanks a lot, I had looking for an easy explanation of this for some time now. You explained wonderfully

  • @JamieKingCS
    @JamieKingCS  Před 11 lety +2

    Thanks for the kind comment!

  • @KeyserTheRedBeard
    @KeyserTheRedBeard Před 2 lety +1

    awesome content Jamie King. I crushed the thumbs up on your video. Keep on up the exceptional work.

  • @JamieKingCS
    @JamieKingCS  Před 12 lety +1

    Thanks for the kind words. Hope the videos help.

  • @pnuema1.618
    @pnuema1.618 Před 2 lety +1

    Even though you believed the "return *this" example in your copy function to be contrived its exactly what I was looking for. I wasn't sure if the * was de-referencing the "this" or if I was looking at new syntax in a very convoluted book my school provided me. Thank you.

    • @tayyab.sheikh
      @tayyab.sheikh Před 4 měsíci +1

      I still didn't understood it, can you please explain what's the use of "*this" ?

  • @barordonez9276
    @barordonez9276 Před 7 lety +3

    Great way to teach the concept of "this" :)

  • @yotsubox1
    @yotsubox1 Před 11 lety

    Thanks so much for this. After reading so much I could not understand it until watching this seven-minute video.

  • @markganus1085
    @markganus1085 Před 7 lety +5

    I'd like to know how returning an object's address value is useful.

    • @goedeck1
      @goedeck1 Před 2 lety

      Maybe analogy would be telling someone your telephone number so you can be reached easily.

  • @LonleyGuns
    @LonleyGuns Před 3 lety

    0:40 Betsy are you pr... this pointer xD

  • @mithunvsadananda3285
    @mithunvsadananda3285 Před 9 lety +1

    Could you please post an video explaining the difference between this and *this.

    • @NursultanBekmuratov
      @NursultanBekmuratov Před 9 lety +8

      Mithun V
      this gives you the adress of instance of a class object, where *this will give you the value stored in that address

  • @ImaginaryHuman072889
    @ImaginaryHuman072889 Před 7 lety +1

    ok makes sense... can someone give an example of a practical use of this this isn't contrived?

  • @djs9patna
    @djs9patna Před 11 lety +1

    I have one doubt like we say "this pointer is const pointer" prototype is
    class_name* const this;
    and in your code sometimes it points to besty and sometimes it points to georgy ,basically you r changing the content of this pointer right?SO ,HOW IT CAN BE A CONST POINTER?

    • @goedeck1
      @goedeck1 Před 2 lety

      Its unique in each instantiation. The betsy this is unique and the georgy this is unique.

  • @T12J7
    @T12J7 Před 2 lety

    Here is a really stupid quetion my brain came up with: If 'this' is a pointer, then how can I access the value stored in that address by using 'this', like inside of method?

    • @JamieKingCS
      @JamieKingCS  Před 2 lety +1

      this->someFieldDataMember

    • @T12J7
      @T12J7 Před 2 lety

      @@JamieKingCS Thanks! :)

  • @medicennacho
    @medicennacho Před 6 lety

    Useful! Thank you

  • @blackbox39999
    @blackbox39999 Před 11 lety

    Thnaks a lot

  • @user-em9mw9ch3y
    @user-em9mw9ch3y Před 6 lety

    Jesus...I am trying to explain it to myself by saying "bobby ..betsy...points to a cow..." and it sounds funny.

  • @maverick140991
    @maverick140991 Před 11 lety

    Thank you!

  • @byteaesx1373
    @byteaesx1373 Před 6 lety

    I'm not gay but I love you dude. Many thanks for the video.

  • @AlanMedina314
    @AlanMedina314 Před 7 lety

    So "this" is a pointer to the objects location on the stack.

  • @vinnidilmurat2774
    @vinnidilmurat2774 Před 6 lety

    what's the difference between " const void printThisPointer()" and " void printThisPointer() const"?

  • @JamieKingCS
    @JamieKingCS  Před 11 lety

    Excellent question. I made some videos to answer just that. I can't post links in a comment box here, but here are the two youtube video codes. Just watch these two videos:
    1- tFjcDICYvE0
    2- PItm2_TZ0wA

  • @superkarl2008
    @superkarl2008 Před 11 lety

    Thanks... it helped a lot~

  • @goedeck1
    @goedeck1 Před 4 lety

    What does the const after the function parentheses do?

    • @FurtoMega
      @FurtoMega Před 4 lety +2

      just tells the compiler that that function only reads, not writes

  • @oleholgerson3416
    @oleholgerson3416 Před 6 lety

    can I pass this as an argument to an outside function?

  • @Mars1990PL
    @Mars1990PL Před 11 lety

    - Let's talk about this.
    - About what?
    :P

  • @vikneshwaran7341
    @vikneshwaran7341 Před 9 lety

    ery nice..........

  • @internascus
    @internascus Před 12 lety

    It helped me :)

  • @nipponese
    @nipponese Před 10 lety

    How are you able define main as a void type? My compiler requires it to be an int.

    • @JamieKingCS
      @JamieKingCS  Před 10 lety +1

      It depends on the compiler. My compiler simply treats void as an int return type and automatically returns 0 for me.

    • @nipponese
      @nipponese Před 10 lety +1

      I see. I guess g++ will only accept an int.

  • @engine_nerd
    @engine_nerd Před 6 lety

    dude... u are full of swag xD lovely... there comes ur like... just the end got a little messy

  • @shihomyano7292
    @shihomyano7292 Před 5 lety

    ابو حسين يا وردة

  • @arturkamalyan4964
    @arturkamalyan4964 Před 6 lety

    i got it bro

  • @magzhanabdibayev3818
    @magzhanabdibayev3818 Před 11 lety

    Жарайсын))

  • @user-hv3ib3kx3f
    @user-hv3ib3kx3f Před 6 lety

    देशराज पटेरिया

  • @keremylmaz9595
    @keremylmaz9595 Před 6 lety

    ->->->-> :D

  • @anzatzi
    @anzatzi Před 12 lety

    Sorry--this is not clear for a student programmer--