I know new and delete are keywords.
int obj = new int;
delete obj;
int* arr = new int[1024];
delete[] arr;
<new> header is a part of C++ standard headers. It has two operators (I am not sure they are operators or they are functions):
::operator new
::operator delete
these operators used like below:
#include <new>
using namespace std;
int* buff = (int*)::operator new(1024 * sizeof(int));
::operator delete(buff);
What are “::operator new” and “::operator delete”? Are they different from new and delete keywords?
::tells the compiler to call the operators defined in global namespace.It is the fully qualified name for the global
newanddeleteoperators.Note that one can replace the global
newanddeleteoperators as well as overload class-specificnewanddeleteoperators. So there can be two versions ofnewanddeleteoperators 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.