What is the official name of C++'s arrow (->) operator?

后端 未结 11 468
死守一世寂寞
死守一世寂寞 2020-12-09 00:47

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.

相关标签:
11条回答
  • 2020-12-09 01:20

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

    0 讨论(0)
  • 2020-12-09 01:22

    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.

    0 讨论(0)
  • 2020-12-09 01:22

    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).

    0 讨论(0)
  • 2020-12-09 01:27

    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.

    0 讨论(0)
  • 2020-12-09 01:27

    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.

    0 讨论(0)
  • 2020-12-09 01:28

    Dereference Pointer

    0 讨论(0)
提交回复
热议问题