1.

How A New Operator Differs From The Operator New?

Answer»

The NEW operator creates a class's new instance. On the other hand, overloading of a new operator is done globally with the help of the operator new. The new operator allocates memory for the ITEM and assigns the address of that memory to the pointer by using the name of an item with a pointer of a DATA type, structure, or array. For example, consider the following code snippet:

Double * pi = new double;

In the PRECEDING code snippet, the new operator returns a pointer to the double variable, because it allocates the SPACE for a double value.

The new operator creates a class's new instance. On the other hand, overloading of a new operator is done globally with the help of the operator new. The new operator allocates memory for the item and assigns the address of that memory to the pointer by using the name of an item with a pointer of a data type, structure, or array. For example, consider the following code snippet:

In the preceding code snippet, the new operator returns a pointer to the double variable, because it allocates the space for a double value.



Discussion

No Comment Found