"added new subtopics on static and dynamic arrays " (#19283)

* "added new subtopics on static and dynamic arrays "

* fix: formatting
This commit is contained in:
rgolu
2018-10-16 00:17:06 +05:30
committed by Aditya
parent 7273305505
commit 9ce249489d

View File

@ -23,8 +23,14 @@ int numbers [] = {1, 2, 3, 4, 5};
//Note that here the number of values defines the size of the array.
//In the examples above, the size was fixed beforehand
```
## Types Of Arrays
There are two types of array based on way, we declare it.
**Note** that arrays in C++ are not permutable in size, which means that once you've declared a array with size 5, it can't be enlarged or made smaller. In case you really need a bigger array with the same entries, you would have to copy all entries to a new array of bigger size.
**1**. Static array:
Those arrays whose size is defined before compile time like in the examples above, are called static arrays. In these arrays we can't change their size, once they are declared.
**2**. Dynamic array:
Dynamic arrays are those arrays, whose size is not known at compile time and we can define their size at run time. These arrays are created by using **new** keyword and when done with that array we can delete that array by using the **delete** keyword.
### Access:
Elements from an array can be accessed via reference of their position in the array. (Start counting from 0).