set::reference

提供对元素的引用类型。集存储区。

typedef typename allocator_type::reference reference;

示例

// set_reference.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   set <int> s1;

   s1.insert( 10 );
   s1.insert( 20 );

   // Declare and initialize a reference &Ref1 to the 1st element
   const int &Ref1 = *s1.begin( );

   cout << "The first element in the set is "
        << Ref1 << "." << endl;
}
  

要求

标头: <set>

命名空间: std

请参见

参考

set 类

标准模板库