What is this?

This is a discussion on What is this? within the C++ Programming forums, part of the General Programming Boards category; if(strcmp(dumn, temp.) data) == 0) count++; temp = temp->next; what is the "->" used for?...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    17

    What is this?

    if(strcmp(dumn, temp.) data) == 0)
    count++;
    temp = temp->next;

    what is the "->" used for?

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    If you have a pointer to a class or struct/union, that is the operator. like:

    struct mystruct
    {
    .....
    }

    mystruct myinstance
    mystruct *mypointer = &myinstance

    then you use mypinter->something in the structure.

    It's just like :: or ., but for a different scope - indirection.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    It is a shortcut for:

    (*pointer).pointer_function_or_variable

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21