Neo wrote:
One quick C++ question.
There are two, but I will forgive you this little bug.
If we declare a bool is it by default initialized to some value? (false or true).
To quote from Stroustrup's book "The C++ Programming Language":
If no initializer is given, a global object, a namespaced object, or a local static object is initialized with a 0 of the appropriate type.
[...]
Local variables (sometimes called automatic objects) and objects created on the heap are not initialized by default.
[...]
Elements of arrays and structures are initialized with the default, depending on whether they are static or not.
Read,
if they are initialized, they are initialized to zero (false). But as sometimes they are
not initialized, it is very wise to initialize them
always to a value of your choosing.
If not what is it n majority of the cases from your experience?
I shudder even
thinking anybody might answer this, or worse, you actually acting on such "knowledge"... one of the 10 Commandments of Programming:
Do not assume. Define, assert, document, but
never assume something that is not documented.