The dynamic array in C++ is called std::vector<T>
with T replaced with the type you want to store in it.
You'll have to put #include <vector>
at the top of your program as well.
e.g.
#include <vector> // instruct the compiler to recognize std::vector
void your_function(std::vector<int> v)
{
// Do whatever you want here
}
int main()
{
std::vector<int> v; // a dynamic array of ints, empty for now
v.push_back(0); // add 0 at the end (back side) of the array
v.push_back(1); // add 1 at the end (back side) of the array
v.push_back(2); // etc...
v.push_back(3);
your_function(v); // do something with v = {0, 1, 2, 3}
v.clear(); // make v empty again
v.push_back(10);
v.push_back(11);
your_function(v); // do something with v = {10, 11}
}
Note to more experienced programmers: yes, a lot of things can be improved here (e.g. const references), but I'm afraid that would only confuse a beginning programmer.