I have following code:
Tools::Logger.Log(string(GetLastError()), Error);
GetLastError() returns a DWORD a numeric
You want to convert the number to a string:
std::ostringstream os;
os << GetLastError();
Log(os.str(), Error);
Or boost::lexical_cast:
Log(boost::lexical_cast<std::string>(GetLastError()), Error);
Since C++11
std::to_string() with overloads for int, long, long long, unsigned int, unsigned long, unsigned long long, float, double, and long double.
auto i = 1337;
auto si = std::to_string(i); // "1337"
auto f = .1234f;
auto sf = std::to_string(f); // "0.123400"
Yes, I'm a fan of auto.
To use your example:
Tools::Logger.Log(std::to_string(GetLastError()), Error);