Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between creating an object,
using 'new' and using 'malloc'?

Answer Posted / sundaram

?new? is used for dynamic memory allocation in C++,
?malloc()? is used for dynamic memory allocation in C.
?new? allocates memory on heap.
?malloc()? allocates memory on heap.
?new? is operator,
?malloc()? is function
?new? returns memory pointer to the correct object on
SUCCESS,
?malloc? returns pointer to void void* on success
?new? throws exception called ?bad_alloc? on FAILURE,
?malloc? returns NULL on FAILURE
?new? is 2 step process
(i) First Allocates memory for a given object
(ii) Calls corresponding destructor if required
?malloc? is one step process ie it allocating only memory.

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How compile and run c++ program in turbo c++?

1178


Can the creation of operator** is allowed to perform the to-the-power-of operations?

993


What is coupling in oops?

1141


What are the different types of comments allowed in c++?

987


Can we use pointers in c++?

1047


Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

4143


What is the difference between structure and class?

1258


Why is polymorphism useful?

1068


How is polymorphism achieved?

1055


Can I run c program in turbo c++?

1032


Is it possible to get the source code back from binary file?

1355


What is implicit pointer in c++?

1076


What is ctime c++?

1125


Who was the creator of c++?

1044


Why is oop useful?

1100