Answer to Question #186901 in C++ for saurav kumar

Question #186901

Explain about new and delete keywords with code


1
Expert's answer
2021-04-29T03:15:29-0400

C++ supports dynamic allocation and deallocation of objects using the new and delete operators. These operators allocate memory for objects from a pool called the free store. The new operator calls the special function operator new, and the delete operator calls the special function operator delete.

int* pInt = new int;   // allocate memory for one variable int type in heap
int* pIntArray = new int[size];  // allocate memory for several variables int type in heap
delete pInt;           // free memomry
delete[] pIntArray;    // free memaory

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS