Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Difference in implementation

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-05-18
What is the difference between malloc() and the new operator?
Question by:trinitrotoluene

Accepted Solution

eranborovik earned 80 total points
ID: 8016460
In most cases new actually calls malloc. The real difference is that new can be overloaded, so the user can
change the way it behaves. For example, maintain a private
pool of memory from which new will take memory.

another thing, new doesn't exist in C but only in C++.
You can safely use malloc also in c++, but you must make sure you call "free" to free the memory. When working with new, you must call "delete" to free the memory.

The most importan thing to notice, is that new also calls
the appropriate object constructor while malloc doesn't.

Expert Comment

ID: 9447522
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question