Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!esosun!net1!sdcsvax!sdcc6!sdcc18!ee161aba From: ee161aba@sdcc18.ucsd.EDU (David L. Smith) Newsgroups: comp.lang.c++ Subject: Passing pointers by reference Message-ID: <572@sdcc18.ucsd.EDU> Date: Mon, 1-Dec-86 04:05:28 EST Article-I.D.: sdcc18.572 Posted: Mon Dec 1 04:05:28 1986 Date-Received: Mon, 1-Dec-86 08:44:40 EST Organization: University of California, San Diego Lines: 27 Is it possible to call a function with a pointer by reference? What I am trying to do is pass a pointer and I want to be able to modify the pointer value (not what it points to). Logically, something like: foo(bar & * junk) should do it. This would be a pointer to bar passed by reference to the function foo. However, this does not work. I attempted to fool the pre-processor by doing: class bar { typdef bar *bar_p; foo(bar_p & junk) } This fools the pre-processor, but the code it produces chokes the C compiler. Specifically, it omits the typedef for bar_p and attempts to use it anyhow without any kind of definition anywhere. I realize I could use a double indirected pointer (and I probably will end up doing so) but I'm lazy and the call by reference is an elegant mechanism. Now if only it would work! David L. Smith UC San Diego sdcsvax!sdcc18!ee161aba