Label::_label; if(_label==NULL){ //初始化_label的代码 } //指针默认值不等于NULL,需要赋初始值Label::_label=NULL;
string str="name is lao wang"; cocos2d::log(str);//这是错误的 cocos2d::log("%s",str);//这是错误的 cocos2d::log(str.c_str());//这才能正确输出 cocos2d::log("%s",str.c_str());//这才能正确输出
std::string str="ab"+"cd";//这是错误的 //正确写法 std::string str="ab"; str+="cd"; log(str.c_str());//输出:abcd
本文介绍Cocos2d-x中正确的日志输出方法及字符串拼接技巧,避免常见错误如直接使用字符串变量输出日志,提供正确的字符串连接方式。
1002

被折叠的 条评论
为什么被折叠?



