I tried to make a function that takes a vector for an argument:
class class0
{
...
...
}
void function (vector <class0> random_vector)
{
...
...
}
int main ()
{
vector <class0> the_vector;
function (the_vector);
...
...
}
It worked. I achieved it with a simple experiment. But I don’t know if there is more to know about doing something like this. Is it the same with the other types of arrays? Is this the best way?
So I need is more info about using any type of arrays as an argument for a function.
You can use templates:
which you call like this:
After re-reading your question, I see you’re more interested in different types of containers.
This can also be achieved with templates:
which you can call like so:
Also, you should pass vector types by
const &for optimization purposes.