Randy said:
No. There were no pointers there.
> What do you think a reference is? It is a pointer
No, it is a reference.
in which the compiler automatically handles
dereferencing. From Schildt's "Teach Yourself C++"
If you manage to derive any worthwhile knowledge from Schildt's books,
you're a genius. Most likely, you're just using wrong source of
information and get confused. If you want to be viewed seriously here,
do not quote from Schildt's books.
2e, in reference to the function "void f(int &n)",
...each time n is used within f(), it is automatically
treated as a POINTER to the argument used to
call f().
I'm sure that is exactly what a implementation does
I am not. Nowhere in the Standard can we read that a reference is
"a pointer that is automatically dereferenced" (or some such). And the
Standard is _infinitely_ more trusted source of information that Schildt's
books.
with references. Anything else (e.g., copying to a
temporary and then recopying when done) would be
insanely inefficient and pointless.
Who said anything about copying? Why can't a reference be implemented in
some other way, like an index or other indirection? If you can't think of
any other way of implementation than pointers, it doesn't mean there can
be none. FWIW, the function can be inlined, and then there are no real
arguments -- everything is as if the body of the function is inserted into
the calling scope and the formal arguments are replaced with the factual
ones.
Pointer isn't a dirty word - don't be afraid to use it.
I am not. No matter what you managed to pollute your brain with by
reading Schildt's books, there were no pointers there. Those were
references, references are not objects, and as such cannot be qualified
as const. Write it on the board 100 times, then report back to us.
V