malloc() and free() versus new and delete
  Next: Memory Leaks Up: Pointers Previous: delete - Syntax

 

    *

      malloc() and free() do not support object semantics
          o Does not construct and destruct objects

string * ptr = (string *)(malloc (sizeof(string)))

    *

      Are not safe
          o Does not calculate the size of the objects that it construct
          o Returns a pointer to void

int *p = (int *) (malloc(sizeof(int)));
int *p = new int;

    *

      Are not extensible
          o new and delete can be overloaded in a class 

