* Marcel:
I am C++ beginner.
When i start building very basic things like hello world programs i am very
attired by the <string> library so i put all text things in strings. Is that
good programmers practice or should i do something else?
It's generally good practice for beginner's code -- and also for
experienced... ;-)
That way you won't hurt yourself.
However, there are some situations where it's ungood, mostly in code
that's not likely to be written by a beginner. Here's an example: you
need a text constant defined in one implementation file, used by some
code in another implementation file. A raw character array constant is
then initialized as part of what the standard calls "static
initialization", which happens before any of your code is executed,
whereas a std::string is an object with a constructor that's executed to
do the initialization, and so it's part of the "dynamic initialization",
which in certain situations just might happen _after_ the code using
that constant is executed -- and bang.
Hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?