1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
// valarray::size example
#include <iostream> // std::cout
#include <valarray> // std::valarray
int main ()
{
std::valarray<int> myvalarray;
std::cout << "1. After construction: " << myvalarray.size() << '\n';
myvalarray = std::valarray<int>(5);
std::cout << "2. After assignment: " << myvalarray.size() << '\n';
myvalarray.resize(3);
std::cout << "3. After downsizing: " << myvalarray.size() << '\n';
myvalarray.resize(10);
std::cout << "4. After resizing up: " << myvalarray.size() << '\n';
return 0;
}
|