I had some different answers on this question before, so decided to ask again here.
Suppose I have a function node* foo() and if some fail accured, I do return NULL. Does this code really return NULL pointer? Or is this NULL a local temporary object? I have no warnings while I compile it. Moreother I can write something like this:
node* ptr = foo();
if (ptr)
printf("Not NULL");
else
printf("NULL");
And it seems like works. (but if this function is, for example const string& foo() it doesn't)
string, did you mean std::string from C++/STL. If you are using C++ (and maybe C++11) please usenullptrU cant return NULL, its temporary object, and somebodythis is absolutly ok.ptr? Who is going to delete it?