WEB 开发 开发语言 Java 技术 .Net 技术 数 据 库 硬件使用
图象媒体 Linux/Unix 移动平台 嵌入开发 Windows 专区 软件工程
Ajax 技术 | ASP | PHP | ASP.NET | C# | JSP | Access | Oracle | 网页设计 | Flash | 安全专题 | IIS | VC/MFC | Delphi | C/C++
 你的位置:首页 > 开发语言 > C/C++

关于vector
[ 来源:ITWENKU 时间:2006-10-27 13:33:03 | 浏览:204人次 ]

那个c++李德vector类 有一个push_back()的函数可以给后面追加对象

那有没有什么函数能从里面删除对象啊?
书上好像没说

我也没找到


pop_back


remove,呵呵


erase
ps:大鸟你当是java的vector呀:)


erase就可以了


erase



那就erase吧。


One important thing to know, the vector.erase() is different from vector.pop_back().

the vector.pop_back() will not delete the object in memory, but the vector.erase() will. so careful, if u just want to pop the object, do not want to delete it, u'd better use the pop_back(), and if u know what u r doing, then the erase() is ok.

and more, the vector.erase() the input value is not int, not like vector.erase(int a), here, the input is a relative value to begin or end, so the right call method is like this:

vecotr.erase(vector.begin()+ (int position));

for vector.pop_back(), it is ok.


more, the vector.erase(vector.begin()); means delete the first element in the vector.


thank u

 相关文章
·函数调用时如何传递另一个函数啊……
·关于在cmd中文件夹名含有空格该如何处理?
·要把另一台电脑上的硬盘加装到我的电脑上,该怎么办?
·这个函数的返回值是?
·做东西编译连接时遇到了问题
·如果想定义一个具有n个元素的数组,杂拌?

 推荐文章
关于高精度乘法的问题
求助c用函数编程
一个关于32位系统的问题
关于堆栈的问题!!!!!
监视哨搜索算法问题
一个矩阵的问题
srting类型的参数传递的问题
请问有什么 c++ design pattern 方面的好书么?
怎样将Turbo C 2.0中的C程序拷贝到 WORD中啊
请说一下 get()函数有什么用.
C++ 中有没现成的函数 可以获得 鼠标所在的某个控件上的整个区域?
我想换个语言用请前辈给点意见
 版权所有:IT问库
copyright © 2006 www.itwenku.cn all rights reserved.