C++ Arrays

C++ Arrays

The group of similar types of elements that have a contiguous memory location is known to be an array in C++. It is basically similar to the arrays available in all other programming languages.

In order to encapsulates the fixed size arrays, std:array is used in the C++ that is basically a container. Please note that the programmers can only store the fixed set of elements in the C++ array and the indexing starts from 0.

Advantages of Arrays in C++

Code Optimization i.e. code writing is less.

Can be accessed randomly.

Its easy to traverse the data

Data can be manipulated easily.

Data can be sorted easily.

Disadvantages of Arrays in C++

There is only one disadvantage that it is of fixed size.

Arrays types in C++

There are generally two types of arrays in C++:

Single Dimensional Array

Multidimensional Array

1. Single Dimensional Array in C++

These are the group of elements that have same datatype and the same name. Here is an example that will elaborate the concept of these arrays: