>>Well, then what is the point of being NULL? Why set it to zero?
In c++ NULL is just a macro (see [URL="http://en.wikipedia.org/wiki/C_preprocessor"]this link[/URL] if you don't know what a macro is) that is defined to be 0. Normally NULL is used to initialize pointers to a known address so … Read More
[B]> Some compilers, such as GCC, automatically initialize integers to 0[/B]
Correction. No compiler initialize an auto variable to anything. Every compiler initialize static variables to 0 (this is mandated by the Standard).
[B]> issue a warning [/B]
At a proper warning level GCC will issue a warning as well. Read More
No, there's a setting under both C::B and VS (but if you were compiling from the command line you could add the switches)
In VS2010: ProjectMenu/<projname>Properties/Configuration Properties/CC++/WarningLevel change to /Wall (I'm not sure what the difference between W4 and Wall is) -- I think this changes it for the project, … Read More
In c/c++ its a good idea to initialize variables to some known state. Unintialized variables causing problem has kept many a programmer debugging for hours.
In C++ Null is defined as 0. See section on "Should I use NULL or 0?" for some words of wisdom from the master himself. … Read More
A structure is a class where members are public by default, besides that technically speaking there are same. However by convention, structures are used to represent simple data structures and classes for more expressive functionality.
For this simple application, it’s not a big deal, but meticulous attention to Constructors and … Read More