C++
雨林一叶
这个作者很懒,什么都没留下…
展开
-
续:一种让数值在指定范围内由小到大再变小的生成方法(固定时间内)
#include "stdafx.h"#include #include#include using namespace std;const static int TIME_PER_FRAME = 100;SYSTEMTIME sys;const static int TOTAL_TIME = 10000;const static int CHANGING_TIMES = 4原创 2013-09-20 02:29:45 · 630 阅读 · 0 评论 -
for each小总结
在需要考虑用for(;;)还是for each(auto ... in ...)的时候,如果不需要用到当前项的索引,可以用for each,否则还是老实用for(;;)吧.不然需要用index的时候还得(1)放个变量index++;(2)获取index的时候index = find(vec.begin(), vec.end(), elem) - vec.begin());都比较麻烦原创 2016-08-10 11:48:15 · 273 阅读 · 0 评论 -
[C++]BOOST_PP_SEQ_FOR_EACH_I根据enum值访问类的不同成员
C++中没有反射机制,所以收到一个枚举的时候想根据枚举名称调用不同的类成员/函数就很麻烦,比如服务器传过来一个枚举enum Property{HP, MP, STR, ...},无法修改服务器端数据结构的情况下想访问Player类中的对应成员,一般情况只能switch(property){case HP: DoSomething(Player.HP); break;case MP原创 2017-04-12 20:36:14 · 2110 阅读 · 0 评论