& symbol

Pages: 12345
Our own tutorial (http://www.cplusplus.com/doc/tutorial/pointers/) refers to '&' as the "Reference operator". That should probably be cleaned up.
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...
closed account (z05DSL3A)
...refers to '&' as the "Reference operator"
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.
closed account (1CfG1hU5)
text information from programming help menu: dos compiler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  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
Last edited on
closed account (1CfG1hU5)
more from dos compiler:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  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
Last edited on
closed account (1CfG1hU5)
i do have visual studio 2013. do not have with me now. different computer.
Well, your help lools like lying pile of crap.

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"
Last edited on
closed account (48T7M4Gy)
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.

Out of interest:

http://www.codingunit.com/cplusplus-tutorial-pointers-reference-and-dereference-operators

Of course they will be totally wrong and irresponsible but hey, that's what makes the world go around. :)


BTW The document is only a working draft, not the standard. Still a chance to get it right.
Last edited on
closed account (1CfG1hU5)
decided to paste some dos compiler text to view. i will take a look at those web pages
closed account (1CfG1hU5)
coding unit page looks good thx
closed account (1CfG1hU5)
Turbo C++ 1 is a VERY old compiler and should be retired by now. Find yourself a new compiler and learn some of the new features of standard C++.


yea it's old doug4, but did you know that turbo c++ 3.0 is used for freedos objects?

i won't retire the language. but i do want to start using my visual studio 2013 more

i like using dos sometimes. happy dosbox is around.
Last edited on
closed account (1CfG1hU5)
dosbox really useful for those old dos games people like. www.abandonia.com
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.
closed account (1CfG1hU5)
got the pdf from

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf

reading...
closed account (1CfG1hU5)
$20 good price for the full manual
closed account (1CfG1hU5)
what's the latest c++ standard? i see 98, 11, 14
what's the latest c++ standard? i see 98, 11, 14
C++14 (or C++1y) is the latest standard. C++1z (C++17 earlier) is in developement.
Last edited on
closed account (48T7M4Gy)
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.
Only a pedant would see such a vapid nuance at work.

Thank goodness for all those pedants working on the standard.


Resorting to a draft standard for authority is considered unprofessional by the ISO.

That must be why it has been recommended publicly by those who work on the standard. Darn those fellows trying to spread their amateurish ways about.
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?
closed account (z05DSL3A)
Only a pedant would see such a vapid nuance at work.
You make it sound like pedantry is a bad thing. Should we all be sloppy and imprecise in our meanings?
Pages: 12345