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

后端 未结 11 469
死守一世寂寞
死守一世寂寞 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:30

    Its just the dit (ie not dot).

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

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

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

    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.

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

    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.

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

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

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