#include <vector>
#include <iostream>
usingnamespace std;
void printvector(const vector<int>& v = vector<int>())
{
vector<int>::const_iterator it;
cout << "vector content: ";
for (it = v.begin(); it != v.end(); it++)
cout << *it;
cout << endl;
}
int main()
{
vector<int> v;
for (int i = 0; i < 10; i++)
v.push_back(i);
printvector();
printvector(v);
}
vector content:
vector content: 0123456789
int c++0x there will be better options like:
vector<int> v = {1,2,3,4,5};
and therefore
void somefunction(int a, const vector<int>& v = {1,2,3,4});
if you use the newest version of g++ or vs they support this maybe. But not sure, you can look it up in the net. Its still no standard, so not recommendable, but good to know.