Re: C++ Pitfall: const objects do not behave constantly.
On Sep 27, 10:27 am, Erik Wikstr=F6m <Erik-wikst...@telia.com> wrote:
C++ is a very powerful language where you can access memory
directly, and there is nothing that prevents you from
modifying that memory (unless it is mapped in read only by the
OS), so there is always a way to get around whatever security
the language provides.
If an object itself is defined const, the compiler is allowed to
put it into read-only memory (unless it contains a mutable
member). Modifying, or attempting to modify, a const object, is
undefined behavior.
"In C++ it's harder to shoot yourself in the foot, but when
you do, you blow off your whole leg."
? Bjarne Stroustrup.
Now that's more relevant to the spaghetti code thread, where C++
not only provides goto, but you have the possibility of
spaghetti inheritance and spaghetti templates as well.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34