Do u have any objection if I use C++11's "nullptr" rather than "0" in the "default" branch? I think it makes the code more readable, and has the advantage that it has its own type (nullptr_t), and thus can't b confused e.g. with int. Therefore, in code like:
Code: Select all
void func(int n);
void func(char *s);
func(NULL);
what will b called is "func(int)", which is of course not the intention. However, if it's called with:
Code: Select all
func(nullptr);
then "func(char*)" will b called, as intended.
I suggest to always use "nullptr" in new code in the "default" branch. Now, as for replacing existing null pointers with "nullptr" - this seems like a very difficult task because there's no easy way to distinguish a "0" which is a null pointer from a "0" which is a number (this is one of the reasons I think "nullptr" is better in the first place!) so I suggest leaving them as is.
http://www.cprogramming.com/c++11/c++11 ... class.html