Jerry Feldman wrote:
That is correct. The point that I wanted to make is that "const int *x" in a function prototype (or "const int& x") communicates to the caller that the object that x points to will not be modified by the function. It also allows the caller to use a pointer to a const object. I got the point and it's a very good answer to a very important question. But I really wanted to know about a trivial technicality: gcc doesn't distinguish, for example, between the following declarations.
int g( int (*const)(int x) ); int g( int (*f)(int const) ); Is this correct behaviour? I'm convinced it doesn't cause any problems (for example conflicting with overloading) bcause both declarations would resolve to int g( int (*)(int) ); it's also plausibly useful, though in the following example, gcc would barf on g but not on f. int f( const int x ); int f( int x ){ return ++x; } int g( int x ); int g( const int x ){ return ++x; } int g( int (*const)( int x ) ); -- JDL Non enim propter gloriam, diuicias aut honores pugnamus set propter libertatem solummodo quam Nemo bonus nisi simul cum vita amittit.