Results 1 to 5 of 5

Thread: What is ->

  1. #1
    NOMADMAN
    Guest

    What is ->

    i've seen -> between say varibles and functions, what does it do?

    NOMAD!

  2. #2
    Zaei
    Guest
    When you use a struct or class, and use its members, you usually use the . operator. But, when you use a pointer to a struct of class, you use the -> operator instead.

    Z.

  3. #3
    NOMADMAN
    Guest
    Wow, thats simple. Thanks Zaei!

    NOMAD

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Basically,

    object->method();

    is equivalent to

    (*object).method();


    it gets very handy when you're chaining pointers to things together like this:

    object->subobject1->subobject2->subobject3->method()

    which would otherwise be

    (*(*(*(*object).subobject1).subobject2).subobject3).method()
    Harry.

    "From one thing, know ten thousand things."

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Oh yes, and if you want to know their proper names:

    . is the 'direct member access operator'

    and

    -> is the 'indirect member access operator'.
    Harry.

    "From one thing, know ten thousand things."

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