Can a new be used in place of old mallocq? If yes, why?



Can a new be used in place of old mallocq? If yes, why?..

Answer / Sanchit Srivastava

Yes, the 'new' operator can replace 'malloc', but it provides additional functionality such as automatic memory deallocation (using 'delete') and constructors for object initialization. However, it is not exactly equivalent to malloc, as new does not support memory alignment control or returning NULL on failure.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is the operator in c++?

1 Answers  


What is the stack?

5 Answers   IBM, ICICI,


What is abstraction in c++ with example?

1 Answers  


What is virtual destructors? Why they are used?

1 Answers  


What is the difference between a class and a structure in C++?

1 Answers  


What is static function? Explain with an example

1 Answers  


Explain the scope resolution operator?

2 Answers  


Can c++ be faster than c?

1 Answers  


Is c++ the best programming language?

1 Answers  


What does it mean to declare a destructor as static?

1 Answers  


What does h mean in maths?

1 Answers  


Why are arrays usually processed with for loop?

1 Answers  


Categories