🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by zweig Wed, 24 May 1989 18:59
const int *, int * not overloadable
#2033
Author: zweig
Date: Wed, 24 May 1989 18:59
36 lines
1574 bytes
It seems like G++ isn't able to tell the difference between a pointer and a const
pointer (i.e. pointer to something you're not allowed to change) for purposes of
operator overloading. For example:

	overload f;
	int f(const int * i)
	{
		return (*i);
	}
	
	int f(int * i)
	{
		return (*i);
	}

produces the error messages:

	In function f (int *):
	tmp.cc:8: conflicting types for `int f (int *)'
	tmp.cc:3: previous declaration of `int f (const int *)'

Thus upshot is that G++ is able to complain about my sending a const int * into
a function that takes an int * (since it might let you illegally change what's
being pointed at), but there's no way to have a function that does the right
thing both for pointers to constant- and pointers to nonconstant values.


-Johnny Zweig
 University of Illinois at Urbana-Champaign
 Department of Computer Science
--------------------------------Disclaimer:------------------------------------
   Rule 1: Don't believe everything you read.
   Rule 2: Don't believe anything you read.
   Rule 3: There is no Rule 3.
-------------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads