to_string()不是std中的成员

方法一:

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

猜你喜欢

转载自blog.csdn.net/twicetwice/article/details/79817343
今日推荐