2011年4月10日

C++ vector 类学习笔记(转)

摘要: 作者: tyc611, 2007-01-15 发表于: http://blog.chinaunix.net/u/18517/showart_232126.htmlvector容器类型 vector容器是一个模板类,可以存放任何类型的对象(但必须是同一类对象)。vector对象可以在运行时高效地添加元素,并且vector中元素是连续存储的。vector的构造函数原型:template<typename T> explicit vector(); // 默认构造函数,vector对象为空 explicit vector(size_type n, const T& v = T() 阅读全文

posted @ 2011-04-10 00:31 Livid 阅读(518) 评论(0) 推荐(0) 编辑

C++ string类的一些函数方法(转)

摘要: string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化此外,string类还支持默认构造函数和复制构造函数,如string s1;string s2="hello";都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常 string类的字符操作:const char &operator[](int n)const;const char &at(int n)const;char &operator[](int n) 阅读全文

posted @ 2011-04-10 00:30 Livid 阅读(988) 评论(0) 推荐(0) 编辑

c++ map的使用方法(转自http://www.cnblogs.com/JCSU/articles/1996876.html)

摘要: /**************************************************************************Map的特点:1、存储Key-value对*2、支持快速查找,查找的复杂度基本是Log(N)*3、快速插入,快速删除,快速修改记*/************************************************************************/#include<stdio.h>#pragmawarning(disable:4786)#include<string>#include<m 阅读全文

posted @ 2011-04-10 00:26 Livid 阅读(3658) 评论(0) 推荐(0) 编辑

导航