共用方式為


valarray::operator-=

從 valarray 運算元減去項目指定的 valarray 或項目型別的值,則為,否則為。

valarray<Type>& operator-=(
   const valarray<Type>& _Right
);
valarray<Type>& operator-=(
   const Type& _Right
);

參數

  • _Right
    項目型別的 valarray 或值與要減去 valarray 的運算元,項目,從 valarray 的運算元。

傳回值

項目是 valarray 這個運算元的差異 _Right.的 valarray

範例

// valarray_op_esub.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   valarray<int> vaL ( 8 ), vaR ( 8 );
   for ( i = 0 ; i < 8 ; i += 2 )
      vaL [ i ] =  10;
   for ( i = 1 ; i < 8 ; i += 2 )
      vaL [ i ] =  0;
   for ( i = 0 ; i < 8 ; i++ )
      vaR [ i ] =  i;
   
   cout << "The initial 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;

   vaL -= vaR;
   cout << "The element-by-element result of "
        << "the difference is the\n valarray: ( ";
      for ( i = 0 ; i < 8 ; i++ )
         cout << vaL [ i ] << " ";
   cout << ")." << endl;
}
  
  
  

需求

標題: <valarray>

命名空間: std

請參閱

參考

valarray Class