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 a base class?

606


What do you mean by volatile and mutable keywords used in c++?

586


What is the difference between prefix and postfix versions of operator++()?

598


When do we use copy constructors?

597


What are signs of manipulation?

599






In what situations do you have to use initialization list rather than assignment in constructors?

639


What are vtable and vptr?

625


Will c++ be replaced?

556


What are c++ tokens?

596


What is setw manipulator in c++?

600


How do I download c++?

575


Can we define a constructor as virtual in c++?

605


How would you use the functions sin(), pow(), sqrt()?

742


what are Operators and explain with an example?

711


What is the use of endl in c++?

599