#include <iostream>
#include <valarray>
using namespace std;
int main()
{
valarray<int> valarrayObject(10), result;
unsigned int i;
for(i = 0; i < 10; i++)
valarrayObject[ i ] = i;
cout << "Contents of valarrayObject: ";
for(i = 0; i <10; i++)
cout << valarrayObject[ i ] << " ";
cout << endl;
result = valarrayObject[slice(0, 5, 2)];
cout << "Contents of result: ";
for(i = 0; i < result.size(); i++)
cout << result[ i ] << " ";
return 0;
}
|