1.

Explain The Concept Of Dynamic Allocation Of Memory?

Answer»

In C++, memory is divided into three areas, AUTOMATIC storage (where function's variables are allocated and stored), static storage (where static data is stored and LEFT for the duration of the program's runtime) and the free storage (the memory set for the use of your code at runtime; the new and DELETE operators are used to allocate and handle space in the free storage).
Allocating the memory dynamically means that you can allocate space for as many elements as you need at runtime. The memory can be allocated dynamically with the new operator and free with the delete operator. Let's understand it with the help of an example-


In the preceding code snippet, allocation of memory is done for a double variable, PI, by using the new operator. This operator returns a pointer to a double variable.

In C++, memory is divided into three areas, automatic storage (where function's variables are allocated and stored), static storage (where static data is stored and left for the duration of the program's runtime) and the free storage (the memory set for the use of your code at runtime; the new and delete operators are used to allocate and handle space in the free storage).
Allocating the memory dynamically means that you can allocate space for as many elements as you need at runtime. The memory can be allocated dynamically with the new operator and free with the delete operator. Let's understand it with the help of an example-


In the preceding code snippet, allocation of memory is done for a double variable, pi, by using the new operator. This operator returns a pointer to a double variable.



Discussion

No Comment Found