Yes, probably. Because C++ standard does not have any mention about "reference operator"
@kemort, also reference requires to be initialized, there cannot be "null reference" (aside from some undefined non-standard operations), references can be used to extend lifetime of temporary...
I remember a long time ago (probably more in the days of C) the two pointer operators (* and &) were often referred to as the dereference and reference operators respectively. The problem appears to be confusion of what something is called (what it is) and what something does.
A pointer is a reference to something but it is not a reference (type). Taking the address of an object is obtaining a reference to the object but it is not a reference (type). We do seem to like to confuse the issue by giving thing inappropriate names.
Referencing/Dereferencing operators ( & * )
The & and * operators work together for referencing and
dereferencing.
The & symbol is also used in C++ to specify reference types,
and as a bitwise AND operator.
You can also use the asterisk as an operator to dereference
a pointer, or as the multiplication operator.
Referencing operator ( & )
In the expression
& cast-expression
the cast-expression operand must be one of the following:
þ a function designator
þ an lvalue designating an object that is
not a bit field and is not declared with
the register storage class specifier
If the operand is of type <type>, the result is of <type>
pointer to type.
Dereferencing operator ( * )
The asterisk (*) in a variable expression creates a pointer
to a type.
In the expression
* cast-expression
the cast-expression must have type "pointer to <type>,"
where <type> is any data type. The result of the indirection
is of type <type>.
If the operand is of type "pointer to function," the result
is a function designator.
If the operand is a pointer to an object, the result is an
lvalue designating that object.
In the following situations, the result of indirection is
undefined:
1. The cast-expression is a null pointer.
2. The cast-expression is the address of an
automatic variable and execution of its
block has terminated.
See also:
operators punctuators
Logical and bitwise operators & ^ | && ||
Turbo C++ offers these bitwise and logical operators:
& bitwise AND
^ bitwise exclusive OR
| bitwise inclusive OR
&& logical AND
|| logical OR
Syntax:
AND-expression & equality-expression
exclusive-OR-expr ^ AND-expression
inclusive-OR-expr | exclusive-OR-expression
logical-AND-expr && inclusive-OR-expression
logical-OR-expr || logical-AND-expression
In these expressions, both operands must be of integral
type:
E1 & E2 E1 ^ E2 E1 | E2
In these expressions, both operands must be of scalar type.
E1 && E2 E1 || E2
The usual arithmetical conversions are performed on E1 and
E2.
For the bitwise operators, each bit in the result is:
Bit value º Results of
in E1 ³ in E2 º E1 & E2 ³ E1 ^ E2 ³ E1 | E2
0 ³ 0 º 0 ³ 0 ³ 0
1 ³ 0 º 0 ³ 1 ³ 1
0 ³ 1 º 0 ³ 1 ³ 1
1 ³ 1 º 1 ³ 0 ³ 1
Unlike the bitwise operators, && and || guarantee
left-to-right evaluation.
E1 is evaluated first; if E1 is zero, E1 && E2 gives 0
(false), and E2 is not evaluated.
With E1 || E2, if E1 is nonzero, E1 || E2 gives 1 (true),
and E2 is not evaluated.
See also:
operators
Here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
This is C++ Standard. It is #1 source for everything related to language, as it is describing how language works. You won't find any mention of "reference operator", but you will find many mentions of "address-of operator"
Strong words. Enough for Vladimir to shoot MAH down.
The reason why the standard doesn't make an issue about the terminology in this case is probably because it isn't an issue. The key word being quibbled about now appears to have shifted to 'operator'. There is no doubt there is a difference between a reference and an address (-of or otherwise) but the subtleties are becoming very esoteric. Almost along the lines of whether + or - should be operators. Hardly worth worring about.
The document is only a working draft, not the standard
Well, you can always pay $20 and get a real copy. This draft is closest one to the C++11 standard. You can get another drafts (all way from C++98 to C++14) and see a consistency in operator naming.
The reason why the standard doesn't make an issue
It doesn't? Because every Standard Comitee member whose speeches I watched refers to that operator as address-of operator and correct people who says "reference operator".
There is no doubt there is a difference between a reference and an address (-of or otherwise) but the subtleties are becoming very esoteric
Difference in context, usage, inner working, guarantees; some of which you are using every day.
Difference in context, usage, inner working, guarantees; some of which you are using every day.
Regrettably, as has been shown that statement is incorrect, in both cases for the word 'suffix' and now 'operator'. Only a pedant would see such a vapid nuance at work.
I have been a chairperson and member on ISO standards and I am very confident that the nuances perceived here and dictated by some would not see the light of day in committee and most certainly would not be used to disparage people acting in good faith, to demean their choice of language, question their motives in contributing, grossly exaggerating small and trivial differences, embarrass people asking for help, being accursedly argumentative, accuse contributors of trolling, calling them a liar and generally misbehaving.
Resorting to a draft standard for authority is considered unprofessional by the ISO.
Resorting to a draft standard for authority is considered unprofessional by the ISO.
Well, I cannot link to the actual standard without violating copyright and "no redistribution" rule. So I have to link closest one. If someone have access to the actual copy, use it instead. If you have some other solution to this problem, I would like to know it.
most certainly would not be used to disparage people acting in good faith, to demean their choice of language
If non-official name causes confusion (and it is, as this topic shows) it is nessesary to discourage its use to avoid further confusion. If official name causes confusion it is worth considering change in terminology.
Maybe we are talking about different things? I am talking about mixing references and result of address-of operator, and by extent mixing pointers and references.
jt1 wrote:
could have said, (int &) is a pointer and a parameter (which has a memory address) ready to receive a pointer to a variable's address, x for example, passed as &x
Which is partially due to terminology mix-up.
It is learning problem, a real problem. Entities which has no relations to each other got mixed up. So for best result it is better to promote non-ambiguous names.
as has been shown that statement is incorrect
Againt what is incorrect? That references and pointers are really two entirely different things? Or that reference declaration and taking an address of variable should not be mixed up and they means different things?