20

Ive almost only programmed in objective-c, for a couple of months ago I programmed a little in box2d and say this "->". Now what does that mean? its cant be objective-c it must be from c++ because box2d is c++, I one time saw someone using it in objective-c code and I just couldn't seem to understand what it did. Google doesn't support non-text characters so its impossible for me to google it since I don't know what it is.

ST3
  • 8,826
  • 3
  • 68
  • 92
Arbitur
  • 38,684
  • 22
  • 91
  • 128
  • 3
    You can probably guess it's an operator. That should be enough to find information on it. – chris Aug 15 '13 at 11:02
  • 3
    "Google doesn't support non-text characters so its impossible for me to google it since I don't know what it is." - But it's an operator, and if you have a bit of imagination, you can deduce that it's an [arrow](http://google.com/search?q=arrow+operator+c). If you don't have any of imagination, that's [still not a problem](https://www.google.com/search?q=dash+greater+than+operator+c) - the characters this symbol is composed of have proper English names such as "dash" and "right angle bracket" or "greater than". –  Aug 15 '13 at 11:16
  • No, the symbol was inherited from C into both Objective-C and C++, with the same meaning in all three (if slightly expanded in C++, where it can be overloaded). – molbdnilo Aug 15 '13 at 11:21
  • 2
    Why was this question downrated? This post was really helpful to me. Thanks for asking the question :). – JPtheK9 May 04 '15 at 00:52
  • 7
    @JPtheK9 Probably because of people thinking this is so basic everyone should know it and get irritated when someone dont :/ And because they thought I didnt google it which i totally tried! – Arbitur May 04 '15 at 01:08
  • 4
    Well this question popped up #1 in my Google search - I think that says something about their assumptions. – JPtheK9 May 04 '15 at 02:02

1 Answers1

27

The -> operator is shorthand for deferencing and then accessing a member.

Given

type *a;

(*a).b is equivalent to a->b

More information here, en.wikipedia.org/wiki

Ash Burlaczenko
  • 24,778
  • 15
  • 68
  • 99
Jonny
  • 2,509
  • 23
  • 42