valarray::value_type
表示項目的型別。valarray 儲存。
typedef Type value_type;
備註
這個型別是樣板參數的 [型別] 一個同義資料表。
範例
// valarray_value_type.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
valarray<int> va ( 10 );
for ( i = 0 ; i < 10 ; i += 2 )
va [ i ] = i;
for ( i = 1 ; i < 10 ; i += 2 )
va [ i ] = -1;
cout << "The initial operand valarray is: ( ";
for ( i = 0 ; i < 10 ; i++ )
cout << va [ i ] << " ";
cout << ")." << endl;
// value_type declaration and initialization:
valarray<int>::value_type Right = 10;
cout << "The decalared value_type Right is: "
<< Right << endl;
va *= Right;
cout << "The resulting valarray is: ( ";
for ( i = 0 ; i < 10 ; i++ )
cout << va [ i ] << " ";
cout << ")." << endl;
}
需求
標題: <valarray>
命名空間: std