有创建的字符串(STD或(常量)字符*)从字符串(为const char *)和数量(INT)创建的,像创建迭代串
animation0,动画1,animation2更好/更快的方式。 .. animation99
比这个?
注:不必须使用std,因为hasValueForKey接受为const char *
std::stringstream strIter("animation0");
int i = 0;
while (hasValueForKey(strIter.str().c_str())) {
// do some stuff
++i;
strIter.str(std::string());
strIter << "animation" << i;
}
感谢
你已经拥有什么可能是最好,最安全的方式(尽管也许你可以跳过一步,并初始化为“动画”而不是空字符串)。 – leegent 2011-05-12 10:31:34