This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: implicit type cast problem of reference of ponter to const type


On Sat, Apr 16, 2005 at 01:13:46PM +0800, Steve Yee wrote:

> the following code can not compile. is it due to the standard?

Yes, this is not valid C++.  int* -> const int* creates a temporary and
you can't bind a non-const reference to a temporary.

You might mean
void testfun(int * const & pr)
or just
void testfun(int * pr)

GCC is correct to reject this code so if you want more information you
should try somewhere like comp.lang.c++

> void testfun(const int *&pr)
> {
> }
> 
> main()

Should be "int main()"

> {
>      int *p;
>      testfun(p);
> }

hope that helps,

jon

-- 
"Democracy is the theory that the common people know what they want, and 
 deserve to get it good and hard."
	- H.L. Mencken


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]