Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!att!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Reference to Pointer Message-ID: <9473@alice.UUCP> Date: 13 Jun 89 19:04:59 GMT References: Distribution: comp.lang.c++ Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 32 In article , neath@solar-1.stars.flab.Fujitsu.JUNET writes: > #include > typedef char* charP; > void bar (const charP& c) { > cout << form ("%s\n", c); > } > void foo (void) { > bar ("HELLO WORLD"); > } > Now, what does it really mean to have a reference to a pointer > to a thing in memory? It means the same kind of thing it means to have a reference to any other type. In this case, when bar is called, c is bound to (a memory cell that contains) a pointer and can be used just as if it were a pointer. Incidentally, the equivalent form void bar (const char*& c) { cout << form ("%s\n", c); } is also legal. C++ 1.2 doesn't accept it because of a bug. C++ 2.0 does accept both forms. -- --Andrew Koenig ark@europa.att.com