Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: How to declare a reference to ptr var Keywords: reference, pointer Message-ID: <468@taumet.com> Date: 2 Oct 90 15:33:01 GMT References: <1990Oct1.163755.20207@bnrgate.bnr.ca> Organization: Taumetric Corporation, San Diego Lines: 20 gwaters@bwdls35.bnr.ca (Glenn Waters) writes: >I have a variable that is declared: > char *x; >I want to call a function saying: > f(x); >How do I declare the function, such that x comes in as a reference var. >I tried a few different ways, to no avail... 1. > f( char * &xr )... 2. > f( char & *xr ) <-- I thought this should really work. No, your example 2 would mean "xr is a pointer to a char reference". Your example 1 is what you want, is legal, and should work -- "xr is a reference to a char*". It does work on two compilers I tried, Oregon C++ and Turbo C++. It sounds like the compiler you are using needs fixing. (Or maybe there is an error in your coding which doesn't show in this question.) -- Steve Clamage, TauMetric Corp, steve@taumet.com