|
From: Ioannis V. <no...@ho...> - 2002-06-15 03:17:59
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Mac Reiter > Sent: Friday, June 14, 2002 9:50 PM > To: Dev-C++ Mailing List > Subject: Re: [Dev-C++] const modifier? > > The compiler should refuse it. Since technically the pointer is only > pointing at the first character, it would not *HAVE* to refuse > modifications to aPtr[1] or any later character, but I believe the C++ > standard makes some special cases to handle arrays of chars > because they > are so prevalent. No, it has to refuse in C too. It remains a const char * in all cases. > > You can also have "char const * anotherPtr", which (if I > haven't screwed > this up) is a constant pointer to non-constant data. That > would mean that: > char const *p is the same as const char *p. You meant char * const p. > I really wish that C had used the Pascal or (modern) BASIC > declaration style: > > Pascal: > MyInteger : INTEGER; > > BASIC: > Dim MyInteger As Integer Thank God it doesn't. :) > or, while I'm dreaming up changes that will never happen -- > it has always > bothered me that "char *" was a pointer, but to get a pointer from a > variable, you used "&variable". From that standpoint, I > would prefer & > instead of * for declaration, resulting in: > > aPtr : & const char; > etc. It could happen but we would still need * since we would confuse the dereference operator with the address of operator, which are different things. > > (Of course, you'd have to come up with a different character > for references > in C++) I also think that @ would be a better dereferencing > operator than > *, because you are trying to access the value "at" an > address. But it's > far too late for these things now, so they will just remain > in my wishful > thinking category... Well yes, these are details. The main idea here is that the C/C++ languages get the job done. One could like more @, another could like more * and i think it is not possible all people to reach an agreement on what symbols to be used. Personally i like things as they are. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |