Re: Compiler strictness


Subject: Re: Compiler strictness
From: Charles Lechasseur (danov@sympatico.ca)
Date: Sat Feb 03 2001 - 09:21:05 CST


At 12:15 AM -0500 3/2/01, Mike Nordell wrote:
>Hubert Figuiere wrote:
>> It looks like Apple compiler is more strict than gcc:
>
>Surprised? :-)
>
>> MrCpp C++ Compiler 4.1.0f1c1
>> Copyright (C) 1994-1999 by Apple Computer, Inc.
>>
>> m_labelTable[index] = pLabel;
>> ^
>> File "ev_Menu_Labels.cpp"; line 119 #Error: can't assign to const variable
>
>I'm almost 100% sure MrCpp is wrong. To be really sure I even tested it on
>como (Comeau) and it says it's allright.
>
>It's not trying to modify the variable, it's trying to modify what it points
>to, which is a non-const EV_Menu_Label*.

actually, i think using const for a member function is not exactly like a
const variable. if you had a const EV_Menu_Label** mArray, then yes, you
could probably get away with what you mention above. but in a const method
you're not supposed to modify the object *at all*, which is definitely not
what you are doing above.

even if the compiler does not enforce it, it's probably better not to flag
a method as "const" if it can actually modify the object. just a thought.

--

charles lechasseur - danov@sympatico.ca http://www3.sympatico.ca/danov/marathon/

"The butts of evil are awaiting my bootprints!" - Minsc



This archive was generated by hypermail 2b25 : Sat Feb 03 2001 - 09:19:01 CST