Results 1 to 5 of 5

Thread: What does -> mean?

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    What does -> mean?

    I was looking at some code and I saw this: ->. I've never seen it before. What does it mean?
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's the pointer-to-member operator
    Code:
    struct mystruct {
        int x;
        char y;
        long z;
    };
    
    void somecode() {
        mystruct thingie;
        mystruct *ptr = &thingie;
    
        int num;
    
        num = ptr->x;
        num = (*ptr).x;
        num = thingie.x;
    }
    The last three accesses all go to the same memory location.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Cool, thanks.
    Alcohol & calculus don't mix.
    Never drink & derive.

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Hey parksie. I havent coded in C++ in ages. A couple of questions.....

    1.) Is the -> operator called the indirect member access operator?
    2.) Is what you are doing with the -> called dereferencing?
    3.)And what is the use of & with "&thingie;"?

    just curiouus.........

    Us Java programmers forget this stuff

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    1. Possibly - the name works
    2. Yes
    3. &var takes the address of var
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width