What is the difference between new() and malloc()?

Answers were Sorted based on User's Feedback



What is the difference between new() and malloc()?..

Answer / nashiinformaticssolutions

• new: Calls constructor, returns an object of the correct type.
• malloc(): Does not call constructor, returns void*.

Is This Answer Correct ?    0 Yes 0 No

What is the difference between new() and malloc()?..

Answer / nashiinformaticssolutions

o new initializes the object and calls its constructor.
o malloc allocates memory but does not call constructors.

Is This Answer Correct ?    0 Yes 0 No

What is the difference between new() and malloc()?..

Answer / glibwaresoftsolutions

• new: Calls constructor, returns an object of the correct type.
• malloc(): Does not call constructor, returns void*.

Is This Answer Correct ?    0 Yes 0 No

What is the difference between new() and malloc()?..

Answer / hr@tgksolutions.com

• new: Calls constructor, returns an object of the correct type.
• malloc(): Does not call constructor, returns void*.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is a parameterized type?

1 Answers  


How do I get good at c++ programming?

0 Answers  


Write an algorithm that determines whether or not an almost complete binary tree is a heap.

0 Answers   TCS,


What are shallow and deep copies?

0 Answers  


There is a array of 99 cells and we have to enter 1-100 elements in it , no two elements would repeat , so the is one no. missing because 99 cells and 1-100 nos. so we had to implement a function to find that missing no.

2 Answers   Nagarro,






Is c++ free?

0 Answers  


What is the use of the this pointer?

3 Answers  


What is a constant? Explain with an example.

0 Answers  


Is c++ pass by reference or value?

0 Answers  


What is the difference between a copy constructor and an overloaded assignment operator?

4 Answers   Belzabar, Citrix, Microsoft, Wipro,


What is the difference between a type-specific template friend class and a general template friend class?

0 Answers  


What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00

0 Answers  


Categories