
c++
文章平均质量分 73
human_cn
这个作者很懒,什么都没留下…
展开
-
对C++ STL,list元素的循环删除操作 //断链,出错地方
1 #include iostream> 2 #include list> 3 #include algorithm> 4 using namespace std; 5 6 int main(int argc, char* argv[]) 7 { 8 listint> MyList; 9 10 for (int i = 0; i 1转载 2012-04-26 15:40:19 · 665 阅读 · 0 评论 -
重大发现:VC++2005,2008或更高版本 之list iterator not incrementable 错误原因
在VC6中list Tlist;list::iterator iter; iter=Tlist.end(); 再iter++;此时iter的游标位置和iter.begin()相等 但在VC6以后的版本中,比如VC2002,2005,2008中list Tlist;list::iterator it转载 2012-04-26 23:39:55 · 430 阅读 · 0 评论 -
list使用中遇到的erase问题(List Iterator Not Incrementable)
list使用中遇到的erase问题(List Iterator Not Incrementable)在VS2005中使用list的erase遇到了"List Iterator Not Incrementable"问题举个例子:1.list sList;list::iterator sP;sList.push_back(1);sList.push_转载 2012-04-27 00:12:01 · 404 阅读 · 0 评论 -
删除stl list 类对象
#include using namespace std;class A{};int main(){lista;for(int i=0;i{a.push_back(new A());}list::iterator i;for(i=a.begin();i!=a.end();i++){delete *i;i=a.erase转载 2012-04-20 13:49:16 · 486 阅读 · 0 评论 -
模板
1. 模板的概念。我们已经学过重载(Overloading),对重载函数而言,C++的检查机制能通过函数参数的不同及所属类的不同。正确的调用重载函数。例如,为求两个数的最大值,我们定义MAX()函数需要对不同的数据类型分别定义不同重载(Overload)版本。//函数1.int max(int x,int y);{return(x>y)?x:y ;}//函数2.转载 2012-05-04 14:12:50 · 230 阅读 · 0 评论 -
C++文件操作详解(ifstream、ofstream、fstream)
C++ 通过以下几个类支持文件的输入输出:ofstream: 写操作(输出)的文件类 (由ostream引申而来)ifstream: 读操作(输入)的文件类(由istream引申而来)fstream: 可同时读写操作的文件类 (由iostream引申而来)打开文件(Open a file)对这些类的一个对象所做的第一个操作通常就是将它和一个真正的文件联系起来转载 2012-05-04 13:56:28 · 369 阅读 · 0 评论 -
string转LPCSTR
调用string.c_str()int main() { const string str1 = "aaaa "; LPCSTR s1 = str1.c_str(); cout return 0; }转载 2012-04-01 22:05:28 · 704 阅读 · 0 评论 -
C语言中字符串的处理方式(一)
写多了 Java 代码,对 String 类 很是喜爱,可惜经典的 C 语言没有。。。最近在做程序过程中,发现对C语言字符串的处理很模糊,一会儿用数组,一会儿用指针,一会儿又引入 string.h。。。于是决定总结一下C语言中字符串的处理,一则作为笔记,二则作为技术交流和大家分享。字符串字面量(字符串常量,在C标准中称为,字符串字面量)如何存储字符串字面量 从本质上而言,C语转载 2012-06-11 11:14:24 · 534 阅读 · 0 评论