Saturday, April 13, 2013

nullptr Vs. NULL

1. We encourage you to use nullptr as we have C++11, the latest version;

2. Whenever a method receives a pointer as a parameter, it can check whether it is equal to nullptr and do the appropriate thing. This is part of good defensive programming. Don't assume other parts of your program are acting as they should. 

2) Are we going to assume that null data will never be inserted in the insert method in BST.hpp?

3. Note that we will not test for this corner case, as we didn't specify that you needed to handle the case in the writeup. 

(This is a general rule, we won't hold you responsible for details left unspecified)
However, testing this corner case could be helpful during code development, much as cassert can be useful

The reason you should use nullptr instead of NULL: http://www.devx.com/cplus/10MinuteSolution/35167

nullptr: A Type-safe and Clear-Cut Null Pointer

Whether you're using NULL or 0, your C++ apps are subjected to bugs and maintenance problems that are caused by the ambiguity of 0. Find out how to use the nullptr keyword instead of 0 to indicate a null pointer value.



No comments:

Post a Comment