How do you allocate and deallocate memory in C++?

Answer Posted / hrpynux@gmail.com

Use the malloc() function to allocate memory in designated blocks and the new function to create a new function. To reallocate memory, the realloc() function is used. When finished, always include a free() function in order to free up the memory. If you used new(), use delete() to free up the memory.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is pure virtual function? Or what is abstract class?

592


Difference between delete and free.

614


Explain data encapsulation?

610


How would you use the functions memcpy(), memset(), memmove()?

624


How do you establish an is-a relationship?

621






What is the difference between a declaration and a definition?

584


what is multi-threading in C++?

615


What are signs of manipulation?

591


What are virtual functions in c++?

689


Is linux written in c or c++?

555


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

1864


What are containers in c++?

567


What are the 3 levels of programming languages?

537


What is the basic concept of c++?

577


Why do we use vector in c++?

602