48

I always call it the "arrow operator", but I'm sure it has an official name. I quickly skimmed the C++ standard and didn't see it mentioned by name.

informatik01
  • 16,038
  • 10
  • 74
  • 104
rmeador
  • 25,504
  • 18
  • 62
  • 103

11 Answers11

64

The C++ standard just calls it "arrow" (§5.2.5).

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
29

Bjarne Stroustrup calls it the "structure pointer dereference" operator (TC++PL Special Edition, p. 102). In the index he refers to it as the "member access" operator.

Not sure if this is "official" but the guy did write the language, after all.

John
  • 15,990
  • 10
  • 70
  • 110
  • 1
    I can confirm that this is the case. (Yes, I actually went to The C++ Programming Language Special Edition and checked it out.) – Thomas Owens Oct 16 '09 at 22:54
  • 22
    he didn't invent C, and that's where the operator comes from. – asveikau Oct 16 '09 at 23:04
  • 2
    asveikau, both of your statements are correct, but what does that have to do with the question? – John Oct 16 '09 at 23:06
  • 4
    asveikau: That's true. But the same operator can have different names in different languages, even though it's the same thing. And the question is specifically about its name in C++. If anything is the answer, this is. – Thomas Owens Oct 16 '09 at 23:07
  • @John W: Well, to be fair, the OP explicitly asked for the *offical* name of the operator. – AnT stands with Russia Oct 16 '09 at 23:10
  • 4
    Please note that TC++PL book is not a formal and/or official source of information on C++ language. TC++PL is deliberately written to be more accessible to beginners. On a number of topics, for the sake of simplicity, it deliberatly contadicts official sources (i.e. speaking pedantically, contains deliberate errors). TC++PL is a good book, but you have to be careful when moving from TC++PL into the "official" world of C++. – AnT stands with Russia Oct 16 '09 at 23:16
15

The official name for this operator is class member access operator (see 5.2.5). Although this name is attached to both . and -> operators, meaning that it's more of a group name. The . is also referred to as dot operator and -> as arrow operator in the standard text.

Added later: The above applies to C++ standard. C standard refers to -> as arrow operator in the Index only. The main text of the document doesn't seem to use any specific name.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765
8

According to Wikipedia's list of operators in C and C++, it's called "member by pointer".

But to be totally honest, I've always called it "arrow". For example, if I had the code a->b, I would read that as "a arrow b".

Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
  • 1
    I found the wikipedia article before I posted the question. Despite the fact that it's listed under the "name" column in the table, I'm inclined to believe that's a description, not a name. – rmeador Oct 16 '09 at 22:53
4

Its just the dit (ie not dot).

James Morris
  • 4,867
  • 3
  • 32
  • 51
3

These terms are in no way official, but I'd call the dot operator the direct (class) member access operator and the arrow operator the indirect (class) member access operator to clarify their relationship with the indirection operator.

Christoph
  • 164,997
  • 36
  • 182
  • 240
2

I've heard it referred to a few different ways, was never sure any one in particular was more official than another.

  • Member Selection Operator
  • Pointer Dereferencing Operator
  • "the arrow thingy"

and I'm sure there are others. personally I'm less concerned about what its called in a book or an official spec and more concerned that people know what I mean when I refer to it, so in my opinion "arrow thingy" is the best name for it since its the easiest to understand clearly what is being referred to.

dbgarf
  • 21
  • 1
2

The index to ISO/IEC 9899:1999 (the C99 standard) has three index entries for 'arrow operator' (in its own right, and under 'union' and 'struct'), and refers to section 6.5.2.3 (Structure and union members, in the section on Postfix operators). However, there is no mention of 'arrow' in section 6.5.2.3 or anywhere else in the standard than the index (every other appearance of 'arrow' is as part of 'narrow' or a derivative of narrow).

Arrow is therefore semi-officially sanctioned in the C standard (the index is not normative or standard setting, though).

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
1

Dereference Pointer

Jonathan D
  • 1,364
  • 2
  • 12
  • 30
1

There was a recent question regarding how the operator is "pronounced" in context. Consider the multiplication operator which is pronounced "times" in context.

I consider both member access operators {. ->} to indicate possession so I pronounce them as a possessive on the object.

For example... fido->collar() ...would be pronounced as "fido's collar".

On the other hand possession isn't appropriate for verbs so... fido->run() ...would be pronounced as "fido runs".

phreed
  • 1,759
  • 1
  • 15
  • 30
  • This is off-topic: The OP asked what the symbol was called, and an answer citing the C++ standard has already been provided. If there was another question regarding the pronunciation of symbols, you should comment there rather than here. – DMH Apr 15 '13 at 15:45
0

The ISO C standard calls it the->operator or the member-access->operator. So apparently it does not have an "official" name in C.

Personally, I just say pointer or arrow.

David R Tribble
  • 11,918
  • 5
  • 42
  • 52