Skip to main content

Sequence Containers: Array

Arrays are fixed-size sequence containers: they hold a specific number of elements ordered in a strict linear sequence.

They cannot be expanded or contracted dynamically


Another unique feature of array containers is that they can be treated as tuple objects


Container properties

    Sequence
    Contiguous storage (allowing constant time random access to elements)
    Fixed-size aggregate





Example:

#include
#include

int main ()
{
  std::array myarray = { 2, 16, 77, 34, 50 };

  std::cout << "myarray contains:";
  for ( auto it = myarray.begin(); it != myarray.end(); ++it )
    std::cout << ' ' << *it;
  std::cout << '\n';

  return 0;
}

Comments