C++ examples for STL:valarray
Representing a Dynamically Sized Numerical Vector
#include <valarray> #include <iostream> using namespace std; int main() {//from www . ja v a 2s .co m valarray<int> v(3); v[0] = 1; v[1] = 2; v[2] = 3; cout << v[0] << ", " << v[1] << ", " << v[2] << endl; v = v + v; cout << v[0] << ", " << v[1] << ", " << v[2] << endl; v /= 2; cout << v[0] << ", " << v[1] << ", " << v[2] << endl; }