上一页 1 2 3 4 5 6 ··· 11 下一页
摘要: #include<iostream>#include<string>#include<algorithm>using namespace std;class MyClass{public: static int num; int data; void DisplayData() { cout<<"Initializion"<<data<<"\n"; } MyClass() { cout<<"MyClass Create\n"; num++; } MyC 阅读全文
posted @ 2012-12-29 14:37 Bug山Bug海 阅读(374) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<string>using namespace std;class Sales_item;//前置申明,让Test识别Sales_itemclass Test{public: void GetName(Sales_item &item); std::string TestName;};class Sales_item{ friend void Test::GetName(Sales_item &item); //freind class Test;的话Test任何方法都能访问public: Sales_ 阅读全文
posted @ 2012-12-26 15:44 Bug山Bug海 阅读(152) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<vector>#include<string>#include<numeric>#include<algorithm>#include<iterator>using namespace std;bool isDivided2(int num){ return num%2==0;}int main(int cnt,char *argv[]){ int l[5]={1,3,3,4,6}; int findl[1]={10}; cout<<accumulate(l 阅读全文
posted @ 2012-12-25 19:07 Bug山Bug海 阅读(358) 评论(0) 推荐(0) 编辑
摘要: 内置函数map(function, iterable, ...)讲传入迭代器的值映射为另一个新值的列表map还可以接受多个iterable作为参数,在第n次调用function时,将使用iterable1[n], iterable2[n], ...作为参数。filter(function, iterable)这个函数的功能是过滤出iterable中所有以元素自身作为参数调用function时返回True或bool(返回值)为True的元素并以列表返回,与系列第一篇中的my_filter函数相同。zip(iterable1, iterable2, ...)这个函数返回一个列表,每个元素都是一个元 阅读全文
posted @ 2012-12-16 16:01 Bug山Bug海 阅读(163) 评论(0) 推荐(0) 编辑
摘要: <stdexcept> 头文件exception 最常见的问题。 以下异常都是exception的子类runtime_error 运行时错误:仅在运行时才能检测到问题 range_error 运行时错误:生成的结果超出了有意义的值域范围 overflow_error 运行时错误:计算上溢 underflow_error 运行时错误:计算下溢 logic_error 逻辑错误:可在运行前检测到问题 domain_error 逻辑错误:参数的结果值不存在 invalid_argument 逻辑错误:不合适的参数 length_error 逻辑错误:试图生成一个超出该类型最大长度的... 阅读全文
posted @ 2012-12-14 14:21 Bug山Bug海 阅读(377) 评论(0) 推荐(0) 编辑
摘要: 常用调试常量__FILE__ 文件名 __LINE__ 当前行号 __TIME__ 文件被编译的时间 __DATE__ 文件被编译的日期 cerr <<"File:"<< __FILE__ <<endl <<"Line:"<< __LINE__ <<endl <<"Date:"<< __DATE__ <<endl <<"Time:"<< __TIME__ <<endl;ND 阅读全文
posted @ 2012-12-14 10:28 Bug山Bug海 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 类型转换:因为要覆盖通常的标准转换,所以需显式使用强制类型转换。显式使用强制类型转换的另一个原因是:可能存在多种转换时,需要选择一种特定的类型转换。我们将在第 14 章中详细讨论这种情况。 命名的强制类型转换符号的一般形式如下: cast-name<type>(expression); 其中 cast-name 为 static_cast、dynamic_cast、const_cast 和reinterpret_castint rst=10;double b=10.23; rst*=static_cast<int>(b);//为了防止把rst转换为double这个不必要 阅读全文
posted @ 2012-12-14 10:27 Bug山Bug海 阅读(893) 评论(0) 推荐(0) 编辑
摘要: 字面值:u 定义为unsignedl 定义为long例:-12u 12l -12ul科学计数:ExF 或者ExLF x代表10的次方数3.14E5F //314000转义:\num num可以是八进制\062,十六进制\xddd字符串:L代表宽字符 L'a' L"a"多行字面值 \ 定义引用:把a的引用给bint a=10;int &b=a;b++;//a,b都为11和以下等价int *b=&a;(*b)++;迭代器:vector<int> v;for(vector<int>::iterator itr=v.begin 阅读全文
posted @ 2012-12-10 10:04 Bug山Bug海 阅读(379) 评论(0) 推荐(0) 编辑
摘要: #!-*-coding: UTF-8 -*-import redef repfuc(match): return "["+match.group(1)+"]"s="111AA22BB33"rnum="(?P\d+)"print(re.match(rnum,s).group(1)) #获取第一个匹配,第一个是整个匹配print(re.match(rnum,s).groups()[0])#获取匹配列表,没有全匹配,和上一个一样print("re.sub")print(re.sub(rnum,&quo 阅读全文
posted @ 2012-12-06 18:41 Bug山Bug海 阅读(341) 评论(0) 推荐(0) 编辑
摘要: open(filepath,mode)打开文件,返回file object mode:a追加,w覆写,不存在文件创建,r读取os.path.join(str[]) 平台相关合并路径,返回合并后路径字符串os.path.split(str) 返回2个项的元组,父路径以及最后一个路径组件分割所有路径函数 : def split_full(path): parent_path,name=os.path.split(path) if name=="": return (parent_path,) else: return split_full(paren... 阅读全文
posted @ 2012-12-06 14:47 Bug山Bug海 阅读(168) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 11 下一页