What's the meanig of ?

what's the meanig of:

1
2
3
    primeirocarro = (struct carro*) new (struct carro);
    if (primeirocarro == NULL)
       exit (1);

?

what is NULL and the function exit();?
Last edited on
Maerle wrote:
what is NULL and the function exit();?


They are programming errors. new will throw a std::bad_alloc exception if it cannot allocate memory.

There is absolutely nothing correct about that code fragment.

You don't need the cast. You don't need the struct specifier. The condition will never evaluate to true. And exit() will never be called. exit() should never be called from a C++ application because certain destructors do not get called.
Topic archived. No new replies allowed.