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...

the difference between new and malloc

Answer Posted / sanish joseph

both malloc and new functions are used for dynamic memory
allocations and the basic difference is: malloc requires a
special "typecasting" when it allocates memory for eg. if
the pointer used is the char pointer then after the
processor allocates memory then this allocated memory needs
to be typecasted to char pointer i.e (char*).but new does
not requires any typecasting. Also, free is the keyword used
to free the memory while using malloc and delete the keyword
to free memory while using new, otherwise this will lead the
memory leak.

Is This Answer Correct ?    13 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are main features of oop?

1178


What is the renewal class?

2813


What is polymorphism what are the different types of polymorphism?

1062


What is coupling in oops?

1218


Can a destructor be called directly?

1132


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

4801


Why is polymorphism used?

1083


What is overriding vs overloading?

1109


Why do pointers exist?

1147


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

2352


Can we have inheritance without polymorphism?

1077


What is the real time example of encapsulation?

1113


What type of loop is a for loop?

1129


Is react oop?

1107


Can main method override?

1148