方法一:
char* PlayLayer::myToString(int count)
{
char* countBuf = new char[25];
sprintf(countBuf, "%d", count);
//point = objectes->getObject(countBuf);
return countBuf;
}
将to_string()替换为std:to_string()
方法二:
首先写一个 stdtostring.h
文件:
#ifndef STDTOSTRING_H
#define STDTOSTRING_H
#include <string>
#include <sstream>
using namespace std;
namespace std
{
template < typename T > std::string to_string( const T& n )
{
std::ostringstream stm ;
stm << n ;
return stm.str() ;
}
}
#endif
然后在需要使用 std::to_stirng()
方法的源文件中包含它:
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #include "stdtostring.h" #endif参考:https://blog.csdn.net/Anzhongliu/article/details/51465507