Normally you just pass the object and the compiler does the rest. No special syntax is needed:
#include <iostream>
#include <vector>
void PrintAll(std::vector<int> const& v)
{
std::vector<int>::const_iterator x = v.begin();
while (x != v.end()) std::cout << *x++ << '\t';
std::cout << '\n';
}
int main()
{
std::vector<std::vector<int> > v;
for (int x = 0; x < 3; ++x)
{
v.push_back(std::vector<int>());
for (int y = 0; y < 5; ++y) v.back().push_back(y);
}
for (int x = 0; x < 3; ++x) PrintAll(v[x]);
} The problem you have is incompatible types. vector is not compatible with vector, and vector is not compatible with vector. There is no way around copying the values into a new vector with whatever explicit or implicit conversions are needed. Your working code is the answer if you cannot change the types of the vectors to match.