Vector Init Array
#include <iostream>
#include <vector>
using namespace std;
void print( vector<int> );
int main()
{
int data[] = {111, 112, 123, 134};
int size = sizeof( data ) / sizeof( data[0] );
vector<int> vec( data, &data[ size ] );
print( vec );
return 0;
}
void print( vector<int> vec ) {
vector<int>::iterator p = vec.begin();
while ( p < vec.end() )
cout << *p++ << " ";
cout << endl;
}
Related examples in the same category