I’ve been programming with SDL for a while, and I decide to make a header file to simplify my coding. Now I have a question; if I pass a function parameter I don’t want, should I do
test(NULL);
from the Windows API I include or
test(false);
I use C++, NOT C.
It completely depends on what the function parameter type is. If it’s a pointer, and the documentation says that it’s valid, then you can pass the C++
NULL(which is just0in reality).Examples:
So not all functions will accept this as valid for a pointer.
It certainly won’t be valid for any other type (though you’ll get away with passing it for an
int, it’s not quite what you’d expect to do).NULLis not a catch-all “I want to opt out of this function parameter”. You simply can’t do that in the general case.Conclusion: It depends what
testis.And I have no idea what
nullis supposed to be.