![]() |
In C++, dynamic arrays allow users to allocate memory dynamically. They are useful when the size of the array is not known at compile time. In this article, we will look at how to initialize a dynamic array in C++. Initializing Dynamic Arrays in C++The dynamic arrays can be initialized at the time of their declaration by using list initialization as shown: data_type* pointer_variableName = new data_type[ array_size] {element1, element2, ...} ;
C++ Program to Initialize Dynamic ArraysC++
Output
Elements of the array are: 1 2 3 4 5
|
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |