c++operator-keywordlanguage-design

Why doesn't C++ have a power operator?


Many languages have a power operator; why doesn't C++? For example, Fortran and Python use ** and is commonly written (in LaTeX, for example) using ^.


Solution

  • C++ does have a power operator—it's written pow(x, y).

    Originally, C was designed with system software in mind, and there wasn't much need for a power operator. (But it has bitwise operators, like & and |, which are absent in a lot of other languages.) There was some discussion of adding one during standardization of C++, but the final consensus was more or less:

    So C++ left things as they were, and this doesn't seem to have caused any problems.