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 searching? Explain linear and binary search.

668


What is private inheritance?

680


What is unary operator? List out the different operators involved in the unary operator.

676


Write a program using display() function which takes two arguments.

702


Difference between Abstraction and encapsulation in C++?

677






Are vectors faster than arrays?

654


What are the unique features of C++.

654


Explain how to initialize a const data member.

704


What is searching?

746


Write a program to add three numbers in C++ utilizing classes.

721


Does a derived class inherit or doesn't inherit?

718


Can create new c++ operators?

655


In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

811


What is the basic difference between C and C++?

709


Explain the difference between realloc() and free() in c++?

635