operator+ (<valarray>)
Erhält die elementweise Summe zwischen entsprechenden Elemente zweier gleichmäßig skalierten Wertarrays oder zwischen einem Wertarrays ein angegebener Wert.
template<class Type>
valarray<Type> operator+(
const valarray<Type>& _Left,
const valarray<Type>& _Right
);
template<class Type>
valarray<Type> operator+(
const valarray<Type>& _Left,
const Type& _Right
);
template<class Type>
valarray<Type> operator+(
const Type& _Left,
const valarray<Type>& _Right
);
Parameter
_Left
Das erste der zwei Wertarrays, deren Elemente hinzugefügt werden sollen oder ein bestimmter für jedes Element eines Wertarrays hinzugefügt werden, Wert._Right
Das zweite der beiden Wertarrays, deren Elemente hinzugefügt werden sollen oder ein bestimmter für jedes Element eines Wertarrays hinzugefügt werden, Wert.
Rückgabewert
Ein Wertearray, dessen Elemente mit elementweise Summe aus _Left und _Right. sind
Beispiel
// valarray_op_esum.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
valarray<int> vaL ( 8 ), vaR ( 8 );
valarray<int> vaNE ( 8 );
for ( i = 0 ; i < 8 ; i += 2 )
vaL [ i ] = 2;
for ( i = 1 ; i < 8 ; i += 2 )
vaL [ i ] = -1;
for ( i = 0 ; i < 8 ; i++ )
vaR [ i ] = i;
cout << "The initial Left valarray is: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaL [ i ] << " ";
cout << ")." << endl;
cout << "The initial Right valarray is: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaR [ i ] << " ";
cout << ")." << endl;
vaNE = ( vaL + vaR );
cout << "The element-by-element result of "
<< "the sum is the\n valarray: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaNE [ i ] << " ";
cout << ")." << endl;
}
Anforderungen
Header: <valarray>
Namespace: std