News for hackers. Stuff that matters.
Re:Initialization in C++ is Bonkers by flavio81 on Monday June 12, 2017 @12:57PM (#14538786)
TL;DR: The author writes a snippet of C++ code where he declares variable but not initializes them. Of course any programmer that has started in C knows that such variables will then have unexpected values.

The author recommends us: "initialize your variables."

Then follows a interesting and fun, but not really important, review of the different ways if initialization in C++. And they are bonkers.

Re:Initialization in C++ is Bonkers by bhk on Monday June 12, 2017 @01:42PM (#14539194)
It would be unimportant if nobody used C++.

Unfortunately, many languages have gotchas like these, and specifications and tutorials often fail to point them out. For the sake of education they should be shouted loudly. You don't really know a language, and aren't really safe using it, until you understand them.

Re:Initialization in C++ is Bonkers by qett on Monday June 12, 2017 @02:08PM (#14539452)
The specifications, at least the C and C++ specifications, absolutely point these things out.
Re:Initialization in C++ is Bonkers by flavio81 on Monday June 12, 2017 @09:16PM (#14542326)
Exactly, i recall that was one of the first things I read, i think, on the Kerninghan&Ritchie classic book ("The C Programming language").

Also on university they repeated to me exactly the same thing. "Since each variable points to a memory location, you can't be sure of what is inside that memory location, until you initialize the variable".