Dynamic Memory Allocation in C++
If you want to create the memory at run time, this concept is used. This allocation is done by ‘new’ and ‘delete’ operators. This happens in heap memory’s portion. Let us create a c++ program to display the memory location. C++ Program: This program includes the header files <iostream> and <memory>. ‘main()’ function is included with pointer variable (*ptr) declaration and assignment of 10 Integer values. The value and address is printed. Code: #include <iostream> #include <memory> using namespace std; int main() { int *ptr; ptr = new int(10); cout << "The value is:"<<*ptr << endl; cout << "The address is:"<<ptr; return 0; } Output: The value is:10 The add...