Search code examples
c++cprogramming-languagesoperators

Are . and -> in C and C++ really operators?


you probably have been tought, are tought yourselves, that . and -> are operators which retrieve members of a struct (C) or class (C++).

However, I doubt they are operators - because, if they are operators, what are their input types? Furthermore, the identifiers on both sides are interdependent - a feature which for example the + operator lacks of.

If this is correct - in what sense are these still labeled as operator in practice, and what is their formal definition with regard to language theory.


Solution

  • This reference says they're both operators in C++:

    http://www.cplusplus.com/doc/tutorial/operators/

    Is that not authoritative enough?