C++ provides several mechanisms for dynamically allocating memory at runtime. Function overloading allows functions to have the same name but different signatures defined by their parameters. Default arguments allow functions to have default values specified if arguments are not provided during a call. Dynamic memory allocation provides flexibility for programs to allocate variable amounts of memory as needed at runtime, such as for linked lists and trees. The new operator requests memory allocation from the heap and returns a pointer to the initialized memory. The delete operator is used to deallocate dynamically allocated memory as it is the programmer's responsibility to free up memory. Enumerated types define a data type where every possible value is a symbolic constant.
1. C++
1. FUNCTION OVERLOADING: The method of using the same function name for different
functions is simply called function overloading. Each function has a unique signature or
different parameters.
2. DEFAULT ARGUMENT: A default argument is an argument to a function that a programmer
is not required to specify. In C++ allow the programmer to specify default arguments that
always have a value, even if one is not specified when calling the function. When a memory
needed depends on user input. On these cases, programs need to dynamically allocate
memory. And this Memory allocated during run time.
3. WHAT ARE APPLICATIONS?
One use of dynamically allocated memory is to allocate memory of variable size which is not
possible with compiler allocated memory except variable length arrays. The most important
use is flexibility provided to programmers. We are free to allocate and deallocate memory
whenever we need and whenever we don’t need anymore. There are many cases where this
flexibility helps. Examples of such cases are Linked List, Tree, etc.
4. NEW OPERATOR: The new operator denotes a request for memory allocation on the Heap. If
sufficient memory is available, new operator initializes the memory and returns the address
of the newly allocated and initialized memory to the pointer variable, new operator is also
used to allocate a block (an array) of memory of type data-type.
5. DELETE OPERATOR: Since it is programmer’s responsibility to deallocate dynamically allocated
memory, programmers are provided delete operator by C++ language. Perhaps the simplest
user-defined data type is the enumerated type. An enumerated type (also called an
enumeration) is a data type where every possible value is defined as a symbolic constant
(called an enumerator). Enumerations are defined via the “enum” keyword. An enumeration
is a user-defined data type that consists of integral constants. To define an enumeration,
keyword “enum” is used.