CPB Mailing List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
const String [] operator
I get a warning from the compiler from the following code.
String Increment(const String& old)
{
if(old[2] < 'a')
{
// some processing
}
}
The warning is 'non-const ... operator[] called for constant object. I
think I understand that the compiler is complaining that [] could change
the passed string 'old' which would be illegal since 'old' is const. The
compile apparently doesn't care that my code doesn't attempt to change
'old'
What syntax can I use to make the comparison I want and still have the
'old' passed as a const but not get a warning?
Thom Burnett
_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]
W Komornicki's Home Page |
Main Index |
Thread Index