On 18/11/2014 9:33 PM, Paul Gilmartin wrote:
Bad history. The original C did not provide "const" so:
o programmers passed string literals to functions that declared them
as "char *" rather than "const char *".
Very true. That's a *good* history lesson.
These days everybody understands const correctness and almost all
runtime libraries demand it. If you see a C function with an input
variable of char * then you should be judicious about using it. Side
effects are evil!
Some languages like Ada have in/out keywords that do a much better job
than C/C++ const. C++ is a different beast because you can have a const
argument that actually copies the input value via a copy constructor
even when you
think it's a constant reference - void( const std::sting & in ).
o In those days, some programmers modified string literals.
So for compatibility with traditional practice and malpractice, the
implied type of a string literal is not const.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN