目录

set::cbegin

描述 (Description)

它返回一个指向容器中第一个元素的const_iterator。

声明 (Declaration)

以下是std :: set :: cbegin在各种C ++版本中的工作方式。

C++98

const_iterator cbegin() const noexcept;

C++11

const_iterator cbegin() const noexcept;

返回值

它返回一个指向容器中第一个元素的const_iterator。

异常 (Exceptions)

它从不抛出异常。

时间复杂

时间复杂性是不变的。

例子 (Example)

以下示例显示了std :: set :: cbegin的用法。

#include <iostream>
#include <set>
int main () {
   std::set<int> myset = {50,40,30,20,10};
   std::cout << "myset contains:";
   for (auto it = myset.cbegin(); it != myset.cend(); ++it)
      std::cout << ' ' << *it;
   std::cout << '\n';
   return 0;
}

上述程序将正确编译和执行。

myset contains: 10 20 30 40 50
↑回到顶部↑
WIKI教程 @2018