返回const随机访问迭代器到容器中的第一个元素。
const_iterator cbegin() const;
返回值
解决const随机访问迭代器第一个元素在 array Class (TR1) 或给成功空 array的位置。应始终返回的值与 array::cend 比较或确保它的 array::end 有效。
备注
array::cbegin的返回值,就不能修改 array 对象。
示例
// array_cbegin.cpp
// compile with: /EHsc
#include <array>
#include <iostream>
int main()
{
    using namespace std;
    array<int, 2> c1 = {1, 2};
    array<int, 2>::const_iterator c1_Iter;
    cout << "The array c1 contains elements:";
    c1_Iter = c1.cbegin();
    for (; c1_Iter != c1.cend(); c1_Iter++)
    {
        cout << " " << *c1_Iter;
    }
    cout << endl;
    // The following line would be an error because iterator is const
    // *c1.cbegin() = 200;
}
要求
标头: <array>
命名空间: std