0

Delete and new implementation

how new and delete are defined If we do not overload new or delete globally , it works and if it was overloaded, global functions defined by us are used when we allocate memory for any data type(basic or custom). If we overload new or delete inside class , these are called when new or delete on same class object is done. How C++ has done this possible in original code of new or delete operator. Any hint or good material is most welcome. Just curious how to implement this functionality by us for some different operator.

11th Jun 2025, 6:19 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 odpowiedzi
+ 1
https://cplusplus.com/doc/tutorial/ see inside classes, if there is what you need.... https://www.geeksforgeeks.org/new-and-delete-operators-in-cpp-for-dynamic-memory/ In C++, the new operator is used to allocate memory dynamically on the heap, while the delete operator is used to deallocate that memory when it is no longer needed. This helps manage memory efficiently and prevents memory leaks by ensuring that every allocation with new has a corresponding delete to free the memory. [Duck.AI : search = cpp new delete] I hope this helps
11th Jun 2025, 7:25 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
I am more concerned about resolution order of function call for this operators
14th Jun 2025, 2:29 PM
Ketan Lalcheta
Ketan Lalcheta - avatar