InterviewSolution
| 1. |
Explain The Difference Between 'operator New' And The 'new' Operator? |
|
Answer» The difference between the two is that operator new just ALLOCATES raw memory, nothing else. The new operator starts by using operator new to allocate memory, but then it invokes the constructor for the right TYPE of OBJECT, so the result is a real live object created in that memory. If that object contains any other objects (either embedded or as base classes) those CONSTRUCTORS as invoked as well. The difference between the two is that operator new just allocates raw memory, nothing else. The new operator starts by using operator new to allocate memory, but then it invokes the constructor for the right type of object, so the result is a real live object created in that memory. If that object contains any other objects (either embedded or as base classes) those constructors as invoked as well. |
|