new expression vs operator new in C++
In C++, there is a new mechanism for memory allocation and management. When we want to initialize an object, we can use new expression to get enough memory for storing an object and also initialize the object. When we want to create a new object, we can use new expression, for example:
Obj *obj=new Obj;
Basically, what the new expression does is to allocate enough memory for storing the obj object, in addition, it will initialize the object with some intial values.
Also, there is an operator new existing in C++, what it does is to allocate raw memory. It only controls allocating memory, not including the initiliation of object. It isn't much different from malloc(). We can call operator new explicitly:
New expression cannot be overloaded, but operator new can be overloaded. You can define your own way to allocate memory in your class implementation.
For more information, you can refer :
When you type abc.xyz, you will see the homepage of Alphabet, the new parent company of Google. But what if you type abc.wtf in your browser address bar? Go and give a try and don't forget to give us a like.