using nullptr instead of NULL when mixing C and C++
Domanda
i have a very simple question...
i am using the SDL API which was written in C. i am using C++. my compiler supports the keyword nullptr, and I've been reading up on it. it seems as if it is better to use rather than using the NULL macro.
when I call SDL_SetVideoMode, I assume it returns NULL on failure, so if i do:
SDL_Surface *test = nullptr;
if ((test = SDL_SetVideoMode(params)) == nullptr)
{
// to-do code
}
will this accurately check if my optimization on the surface test was successful?
Soluzione
Yes. nullptr is comparable to and equivalent to a null pointer of any other pointer type.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow