C++ named operators

December 29, 2007



Can someone explain to me the rationale behind C++ named operators? Here I am, trying to define things that operate in boolean logic, and I can’t use the names “and”, “or”, and “not”. Thank you very much. Perhaps the C++ standards committee thought they weren’t reserving enough keywords?



Jon Reid

Posts Twitter Google+

As an American missionary kid who grew up in Japan, I'm a child of two cultures, while not fully belonging to either. This gives me a sightly different view of the world.

4 responses to C++ named operators

  1. Well being as it is a standard preprocessor keyword you can do a #undef and then redefine it. Something us C programmers do all the time. 🙂

  2. No can do, Jason:
    error: “not” cannot be used as a macro name as it is an operator in C++
    It’s a genuine keyword.
    Feh.

  3. How about NOT? Mmm, smells like COBOL, doesn’t it? 😀