query about memory allocation

Hi friends,
Could any one tell me about the differences between calloc, malloc,new and delete and their implementation.

Comments

  • [b][red]This message was edited by stober at 2006-2-28 7:39:36[/red][/b][hr]
    : Hi friends,
    : Could any one tell me about the differences between calloc, malloc,new and delete and their implementation.
    :


    try using google or reading any introductory text book. Here is an example

    http://www.cplusplus.com/doc/tutorial/dynamic.html

    In a nutshell, c++ uses new and delete, C use malloc(), calloc() and free(). you can use malloc() and calloc() in c++ too but not on c++ classes. c++ new calls the class constructor after the memory has been allocated, malloc() and calloc() do not.







  • : [b][red]This message was edited by stober at 2006-2-28 7:39:36[/red][/b][hr]
    : : Hi friends,
    : : Could any one tell me about the differences between calloc, malloc,new and delete and their implementation.
    : :
    :
    :
    : try using google or reading any introductory text book. Here is an example
    :
    : http://www.cplusplus.com/doc/tutorial/dynamic.html
    :
    : In a nutshell, c++ uses new and delete, C use malloc(), calloc() and free(). you can use malloc() and calloc() in c++ too but not on c++ classes. c++ new calls the class constructor after the memory has been allocated, malloc() and calloc() do not.
    :
    :
    :


    It is also worth mentioning that you never should mix new with free() or malloc() with delete. They are not compatible with each other.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories