* Jack Klein:
On Sun, 29 Oct 2006 18:02:36 +0100, "Alf P. Steinbach"
<al***@start.nowrote in comp.lang.c++:
>* Alex Vinokur:
>>What is the difference between an operator and a function in C++?
An operator is a special kind of function, with a non-alphanumeric name,
an operator symbol, which can be invoked using prefix, infix or postfix
notation, e.g.
The concept of "special kind of function" is a very strange one,
No, it's not a strange concept, it's the basic idea.
The standard calls it an "operator function" (some operator functions
can be user-defined).
and
certainly not supported by any wording in the C++ language.
Yes, the standard does not AFAIK define the general concept of
operators. AFAIK there's not even a list of operators, except if a
table with punctuation symbols thrown in is OK. The reader is simply
supposed to already have a working notion of what operators are.
The notion that operators must have a non-alphanumeric name is quite
easily refuted by the following operators:
- sizeof
- const_cast
- static_cast
- dynamic_cast
- reinterpret_cast
In addition to those there's 'new', 'delete', 'and', 'and_eq', 'bitand',
'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', 'xor' and 'xor_eq'.
So clearly an operator mustn't necessarily have a non-alphanumeric name.
But operators /usually/ are non-alphanumeric (those I listed here,
except the two first, are in practice not used, and those you listed
cannot be overridden, so these alphanumeric operators are very special
cases), and since they usually are, they /can/ be non-alphanumeric.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?