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) 编辑

static

摘要: 1. 静态全局变量在全局变量前,加上关键字static,该变量就被定义成为一个静态全局变量 1) 该变量在全局数据区分配内存; 2) 未经初始化的静态全局变量会被程序自动初始化为0(自动变量的值是随机的,除非它被显式初始化); 3) 静态全局变量在声明它的整个文件都是可见的,而在文件之外是不可见... 阅读全文

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

导航