上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页

2014年10月26日

常用算法

摘要: 二分查找int binary_search(int a[],int len,int goal){ int beg = 0; int end = len - 1; while(beg goal) end = middle - 1; else ... 阅读全文

posted @ 2014-10-26 18:02 kangbry 阅读(225) 评论(0) 推荐(0) 编辑

字符串算法

摘要: 字符串逆转void reverse(char* str,int beg,int end){ int times = (end- beg +1)/2; while(times > 0) { char tmp = str[end]; str[end--] =... 阅读全文

posted @ 2014-10-26 16:31 kangbry 阅读(149) 评论(0) 推荐(0) 编辑

2014年10月25日

左值右值

摘要: C/C++语言中可以放在赋值符号左边的变量,左值表示存储在计算机内存的对象,左值相当于地址值。右值:当一个符号或者常量放在操作符右边的时候,计算机就读取他们的“右值”,也就是其代表的真实值,右值相当于数据值 阅读全文

posted @ 2014-10-25 14:51 kangbry 阅读(142) 评论(0) 推荐(0) 编辑

异常处理

摘要: 1) 异常的抛出和处理主要使用了以下三个关键字:try, throw, catch 2) 抛出异常即检测是否产生异常,在C++中,其采用throw语句来实现,如果检测到产生异常,则抛出异常。该语句的格式为:throw 表达式;3) 在try语句块的程序段中(包括在其中调用的函数)发现了异常,且抛弃了... 阅读全文

posted @ 2014-10-25 13:52 kangbry 阅读(264) 评论(0) 推荐(0) 编辑

extern inline volatile explicit

摘要: 1. extern是一个关键字,它告诉编译器存在着一个变量或者一个函数,如果在当前编译语句的前面中没有找到相应的变量或者函数,也会在当前文件的后面或者其它文件中定义2. 调用extern "C"关键字,声明cpp文件中有关代码,需要按照C的方式来生成1. 在函数声明或定义中函数返回类型前加上关键字i... 阅读全文

posted @ 2014-10-25 13:05 kangbry 阅读(315) 评论(0) 推荐(0) 编辑

2014年10月24日

const

摘要: const作用 1) 可以定义const常量 const int max = 1002) 对传入的参数进行类型检查,不匹配进行提示 void f(const int i) { .........}3) 可以保护被修饰的东西 void f(const int i) { i=10;//error! }4... 阅读全文

posted @ 2014-10-24 22:29 kangbry 阅读(669) 评论(0) 推荐(0) 编辑

场景管理aoi

摘要: enter事件1. 离开旧场景2. 进入新场景 3 move事件4 on_enter leave事件1 uid --> old_cell 2 leavel_cell on_leave 广播离开事件move事件1 uid --> old_cell 2 pos --> new_cell 3 a. 存在o... 阅读全文

posted @ 2014-10-24 15:22 kangbry 阅读(471) 评论(0) 推荐(0) 编辑

序列化tinybuf

摘要: /* ------------------------------------------------------------------------------- | 数据头标记(1字节) | ID标识字段(不一定有) | ------------------------------------... 阅读全文

posted @ 2014-10-24 09:18 kangbry 阅读(126) 评论(0) 推荐(0) 编辑

模板特化

摘要: templateclass Compare{public: static bool IsEqual(const T& lh, const T& rh) { return lh == rh; }};View Code1) 特化为绝对类型 int i1 = 10;... 阅读全文

posted @ 2014-10-24 09:05 kangbry 阅读(158) 评论(0) 推荐(0) 编辑

C++类型转换

摘要: const_cast 去掉类型的const或volatile属性。 struct SA { int i; }; const SA ra; //ra.i = 10; //直接修改const类型,编译错误 SA &rb = const_castSA&>(ra); rb.i = 10;... 阅读全文

posted @ 2014-10-24 00:11 kangbry 阅读(89) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页

导航