欢迎来到天天文库
浏览记录
ID:14791398
大小:70.50 KB
页数:8页
时间:2018-07-30
《c++ stl之array的用法》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Array容器的相关知识,array是一个顺序容器,和其他标准容器相比它的特点是容器的大小固定,顺序存储。1:array的构造函数array();array(constarray&right);2:array的成员变量TypeDefinitionDescriptionarray::const_iteratorThetypeofaconstantiteratorforthecontrolledsequence.array::const_pointerThetypeofaconstantpointertoanelement.array::const_referenceThetyp
2、eofaconstantreferencetoanelement.array::const_reverse_iteratorThetypeofaconstantreverseiteratorforthecontrolledsequence.array::difference_typeThetypeofasigneddistancebetweentwoelements.array::iteratorThetypeofaniteratorforthecontrolledsequence.array::pointerThetypeofapointertoanelement.arra
3、y::referenceThetypeofareferencetoanelement.array::reverse_iteratorThetypeofareverseiteratorforthecontrolledsequence.array::size_typeThetypeofanunsigneddistancebetweentwoelements.array::value_typeThetypeofanelement.3:array的关于迭代器的成员函数IteratorsbeginReturniteratortobeginning (publicmemberfuncti
4、on)endReturniteratortoend (publicmemberfunction)rbeginReturnreverseiteratortoreversebeginning (publicmemberfunction)rendReturnreverseiteratortoreverseend (publicmemberfunction)cbeginReturnconst_iteratortobeginning (publicmemberfunction)cendReturnconst_iteratortoend (publicmemberfunction)crb
5、eginReturnconst_reverse_iteratortoreversebeginning (publicmemberfunction)crendReturnconst_reverse_iteratortoreverseend (publicmemberfunction)这些东西和list中迭代器都类似,在list篇中已经做过大量介绍,这里就不再啰嗦了。4:array中关于容量的函数CapacitysizeReturnsize (publicmemberfunction)max_sizeReturnmaximumsize (publicmemberfunction)
6、emptyTestwhetherarrayisempty (publicmemberfunction)4.1size()函数的用法,从结果中可以看出array容量的一些端倪来。size_typesize()const;#include#includeintmain(){std::arraymyints;std::cout<<"sizeofmyints:"<7、0;}结果:sizeofmyints:5sizeof(myints):204.2max_size()函数的用法,说明这个函数和list中的max_size()的不同size_typemax_size()const;#include#includeintmain(){std::arraymyints;std::cout<<"sizeofmyints:"<
7、0;}结果:sizeofmyints:5sizeof(myints):204.2max_size()函数的用法,说明这个函数和list中的max_size()的不同size_typemax_size()const;#include#includeintmain(){std::arraymyints;std::cout<<"sizeofmyints:"<
此文档下载收益归作者所有