How would I dynamically add a value (push) to an array? I could do this in AS3, but I can't find a function for it in C++.
You can't if it's a statically defined array like so:
int array[10];
Its size is fixed. However, if you use a container such as std::vector you'd use:
std::vector::push_back()
It is not possible to 'push' in a statically allocated classic C-style array and it would not be a good idea to implement your own 'method' to dynamically reallocate an array, this has been done for you in the STL, you can use vector:
#include <vector>
// ...
std::vector<int> vect;
vect.push_back(1);
vect.size(); // --> 1
vect.push_back(2);
vect.size(); // --> 2
// ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With