Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
array::begin

array::begin

Designates the beginning of the controlled sequence.

iterator begin() noexcept;
const_iterator begin() const noexcept;

The member functions return a random-access iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).

 

// std_tr1__array__array_begin.cpp 
// compile with: /EHsc 
#include <array> 
#include <iostream> 
 
typedef std::array<int, 4> Myarray; 
int main() 
    { 
    Myarray c0 = {0, 1, 2, 3}; 
 
// display contents " 0 1 2 3" 
    for (Myarray::const_iterator it = c0.begin(); 
        it != c0.end(); ++it) 
        std::cout << " " << *it; 
    std::cout << std::endl; 
 
// display first element " 0" 
    Myarray::iterator it2 = c0.begin(); 
    std::cout << " " << *it2; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 0

Header: <array>

Namespace: std

Show:
© 2015 Microsoft