new vs operator new in C++ Last Updated : 21 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report When you create a new object, memory is allocated using operator new function and then the constructor is invoked to initialize the memory. Here, The new operator does both the allocation and the initialization, where as the operator new only does the allocation. Let us see how these both work individually. new keyword The new operator is an operator which denotes a request for memory allocation on the Heap. If sufficient memory is available, new operator initializes the memory and returns the address of the newly allocated and initialized memory to the pointer variable. When you create an object of class using new keyword(normal new). The memory for the object is allocated using operator new from heap.The constructor of the class is invoked to properly initialize this memory. CPP // CPP program to illustrate // use of new keyword #include<iostream> using namespace std; class car { string name; int num; public: car(string a, int n) { cout << "Constructor called" << endl; this ->name = a; this ->num = n; } void enter() { cin>>name; cin>>num; } void display() { cout << "Name: " << name << endl; cout << "Num: " << num << endl; } }; int main() { // Using new keyword car *p = new car("Honda", 2017); p->display(); } Output: Constructor called Name: Honda Num: 2017Operator new Operator new is a function that allocates raw memory and conceptually a bit similar to malloc(). It is the mechanism of overriding the default heap allocation logic.It doesn't initializes the memory i.e constructor is not called. However, after our overloaded new returns, the compiler then automatically calls the constructor also as applicable.It's also possible to overload operator new either globally, or for a specific class CPP // CPP program to illustrate // use of operator new #include<iostream> #include<stdlib.h> using namespace std; class car { string name; int num; public: car(string a, int n) { cout << "Constructor called" << endl; this->name = a; this->num = n; } void display() { cout << "Name: " << name << endl; cout << "Num: " << num << endl; } void *operator new(size_t size) { cout << "new operator overloaded" << endl; void *p = malloc(size); return p; } void operator delete(void *ptr) { cout << "delete operator overloaded" << endl; free(ptr); } }; int main() { car *p = new car("HYUNDAI", 2012); p->display(); delete p; } Output: new operator overloaded Constructor called Name:HYUNDAI Num:2012 delete operator overloadedNew operator vs operator new Operator vs function: new is an operator as well as a keyword whereas operator new is only a function.New calls "Operator new": "new operator" calls "operator new()" , like the way + operator calls operator +()"Operator new" can be Overloaded: Operator new can be overloaded just like functions allowing us to do customized tasks.Memory allocation: 'new expression' call 'operator new' to allocate raw memory, then call constructor. Comment More infoAdvertise with us Next Article Operators in C++ Y Yash Singla Improve Article Tags : Difference Between C++ Dynamic Memory Allocation Practice Tags : CPP Similar Reads Operators in C++ C++ operators are the symbols that operate on values to perform specific mathematical or logical computations on given values. They are the foundation of any programming language.Example:C++#include <iostream> using namespace std; int main() { int a = 10 + 20; cout << a; return 0; }Outpu 9 min read Placement new operator in C++ Placement new is a variation new operator in C++. Normal new operator does two things : (1) Allocates memory (2) Constructs an object in allocated memory. Placement new allows us to separate above two things. In placement new, we can pass a preallocated memory and construct an object in the passed m 6 min read map::operator[] in C++ STL Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have same key values. map::operator[] This operator is used to reference the element present at position given inside the operator. It is similar to the 2 min read list::operator= in C++ STL Lists are containers used in C++ to store data in a non contiguous fashion, Normally, Arrays and Vectors are contiguous in nature, therefore the insertion and deletion operations are costlier as compared to the insertion and deletion option in Lists. list::operator= This operator is used to assign n 2 min read Conversion Operators in C++ In C++, the programmer abstracts real-world objects using classes as concrete types. Sometimes, it is required to convert one concrete type to another concrete type or primitive type implicitly. Conversion operators play an important role in such situations. It is similar to the operator overloading 4 min read Unary Operators In C++ In C++, unary operators are the type of operators that work on a single value (operand). They perform operations like changing a value's sign, incrementing or decrementing it by one, or obtaining its address.C++ has a total of 9 unary operators:Table of ContentIncrement Operator (++)Decrement Operat 6 min read Like