I know new
and delete
are keywords.
int obj = new int;
delete obj;
int* arr = new int[1024];
delete[] arr;
::
tells the compiler to call the operators defined in global namespace.
It is the fully qualified name for the global new
and delete
operators.
Note that one can replace the global new and delete operators as well as overload class-specific new and delete operators. So there can be two versions of new
and delete
operators in an program. The fully qualified name with the scope resolution operator tells the compiler you are referring to the global version of the operators and not the class-specific ones.