Check out example codes for "heap allocated array in c ++". It will help you in understanding the concepts better.

Code Example 1

//Heap array
std::array<myarray, 3> stack_array; // Size must be declared explicitly.VLAs

//Stack array
std::vector<myarray> heap_array (3); // Size is optional.

Code Example 2

//                                 Heap allocated array in c++
//using std::vector
#include <vector>
std::vector<myarray> bestArray(100); //A vector is a dynamic array, which (by default) allocates elements from the heap

//or managing memory yourself
myarray* heapArray = new myarray[100];
delete [] heapArray; // when you're done

//How to use vector to put elements inside the array.
// C++11:
std::vector<myarray> bestArray{ 1, 2, 3 };

// C++03:
std::vector<myarray> bestArray;
bestArray.push_back(myarray(1));
bestArray.push_back(myarray(2));
bestArray.push_back(myarray(3));

Learn ReactJs, React Native from akashmittal.com