﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-fov42550564-文章分类-C++</title><link>http://www.cppblog.com/fov42550564/category/6931.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 04 Jun 2008 15:30:28 GMT</lastBuildDate><pubDate>Wed, 04 Jun 2008 15:30:28 GMT</pubDate><ttl>60</ttl><item><title>vector的用法</title><link>http://www.cppblog.com/fov42550564/articles/vector.html</link><dc:creator>ぢ冷lo★ve月</dc:creator><author>ぢ冷lo★ve月</author><pubDate>Fri, 02 May 2008 02:40:00 GMT</pubDate><guid>http://www.cppblog.com/fov42550564/articles/vector.html</guid><wfw:comment>http://www.cppblog.com/fov42550564/comments/48625.html</wfw:comment><comments>http://www.cppblog.com/fov42550564/articles/vector.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/fov42550564/comments/commentRss/48625.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/fov42550564/services/trackbacks/48625.html</trackback:ping><description><![CDATA[<p>vector 抽象容器类型之一（还有list和deque等），与其他几中容器类型不同的是它高效支持随机访问其中的元素。 <br>使用vector，首先必须调用头文件(#include &lt;vector&gt;) </p>
<p>它的声明和初始化是这样的 <br>vector &lt;类型名&gt; 变量名 <br>vector &lt;int&gt; vi = ( 10 , 1 ) //初始化为10个元素的vector，每个元素都为1 </p>
<p>push_back()的用法是将元素插入vector容器的最尾部 <br>举个例子 <br>vector &lt;int&gt; vi; <br>int a[4] = { 0, 1, 2, 3}; <br>for ( int i = 0; i&lt;=4; ++i ) <br>vi.push_back(a[i]); </p>
<p>此时vi就是0 1 2 3 <br>如果改成 <br>vi.push_front( a[i] ); <br>vi就是 3 2 1 0<br>参考资料：C++ Primer</p>
<img src ="http://www.cppblog.com/fov42550564/aggbug/48625.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/fov42550564/" target="_blank">ぢ冷lo★ve月</a> 2008-05-02 10:40 <a href="http://www.cppblog.com/fov42550564/articles/vector.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>