For the first three cases, the compiler complains because the only difference between the parameters is whether they're const or not. Since the parameters are passed by copy, a valid call to one version is also a valid call to the other, so it would be ambiguous.
It doesn't make much sense to return or take const things, anyway.
1 2 3
int a=rConstInt();
constint *p=rConstIntConstPtr();
X x=rConstX();
However there is a difference between char const * and char * const:
1 2 3 4 5 6 7 8 9
charconst* cstr_ptr = newchar[1]; // can not modity the char
char* const str_cptr = newchar[1]; // can not modify the pointer
*cstr_ptr = 'N'; // illegal can not change the char it points to
*str_cptr = 'Y'; // okay
cstr_ptr = 0; // okay
str_cptr = 0; // illegal can not change the pointer
Yes, when it's not done in good faith. For example, when two users are having a heated argument and one of them later goes and, because he can't delete posts after they've been replied to, blanks them.
I must admit when I scanned this thread I did wonder what helios was talking about, but that was because I thought the previous three post where from different people not the same person. I don't alway look at who has posted just what, so it was a bit odd.
When you use char* c =newchar[10]; then nothing is const.
1 2 3 4 5 6 7 8 9 10
charconst *c="new";
constchar *c1="newc";
*c="new str"; // *c is a single char and you are trying to assign a char* to it (which is the address of a char)
*c1="newc str";
// Do you mean this?
c = "new str";
c1 = "newc str";
As noted above const char* and char const* are identical.
constchar *c11= newchar[20];
char * const c12=newchar[20];
c11[0]=0; //Error. c11 is a pointer to a constant character.
c11=0; //OK. The pointer can be changed.
c12[0]=0; //OK. The thing being pointed to can be changed.
c12=0; //Error. c12 is a constant pointer to a character