次の方法で共有


vector::operator (STL/CLR)

指定した位置にある要素にアクセスします。

    reference operator[](size_type pos);

パラメーター

  • pos
    アクセスする要素の位置。

解説

メンバー演算子は pos場所で要素に referene を返します。位置をがわかっている要素にアクセスするときに使用します。

使用例

// cliext_vector_operator_sub.cpp 
// compile with: /clr 
#include <cliext/vector> 
 
int main() 
    { 
    cliext::vector<wchar_t> c1; 
    c1.push_back(L'a'); 
    c1.push_back(L'b'); 
    c1.push_back(L'c'); 
 
// display contents " a b c" using subscripting 
    for (int i = 0; i < c1.size(); ++i) 
        System::Console::Write(" {0}", c1[i]); 
    System::Console::WriteLine(); 
 
// change an entry and redisplay 
    c1[1] = L'x'; 
    for (int i = 0; i < c1.size(); ++i) 
        System::Console::Write(" {0}", c1[i]); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

必要条件

ヘッダー: <cliext とベクター>

名前空間: の cliext

参照

関連項目

vector (STL/CLR)

vector::at (STL/CLR)