What does -> do? RRS feed

  • Question

  • Have briefly searched for information on the following :


    What does the above do? Can`t find any documentation on it.

    Tuesday, June 23, 2015 9:01 PM


All replies

  • In simple terms you can say you use  -> for accessing object member variables and methods via pointer to object. Check for operators in C or C++ book


    Rupesh Shukla

    Tuesday, June 23, 2015 9:05 PM
  • The code


    is functionally identical to

    If the second syntax is also confusing to you, you should probably look up a tutorial on C/C++ pointers and/or C/C++ structures and classes (depending on whether the * or the . is confusing to you).
    • Proposed as answer by Jim Brunne Wednesday, June 24, 2015 12:20 AM
    Tuesday, June 23, 2015 10:33 PM
  • If you have a structure or class then that structure or class has members. Here's one with two members:

    typedef struct {
        UINT iNumIndices ;
        UINT Indices[MAX_PFACE_INDICES] ;
    } MeshFace_t ;

    If you have a MeshFace you can use . to get at the members:

    MeshFace_t MF = ...blah blah
    MF.iNumIndices = 5 ;

    If you have a pointer to a mesh face you use "->" instead of "."

    MeshFace_t* pMF = ...blah blah
    MF->iNumIndices = 5 ;

    -> Is a way of getting at structure or class members when you have a pointer to the structure or class.

    http://www.ransen.com Cad and Graphics software

    • Proposed as answer by Owen Ransen Wednesday, June 24, 2015 5:15 AM
    Wednesday, June 24, 2015 5:14 AM
  • ->

    What does the above do? Can`t find any documentation on it.

    There's abundant documentation available. For example:

    Member Access Operators: . and ->

    Member access operators

    Also see:

    Pointer-to-Member Operators: .* and ->*

    - Wayne

    • Marked as answer by Shu 2017 Thursday, July 2, 2015 4:11 AM
    Wednesday, June 24, 2015 6:25 AM