如何将Platform ^ string转换为wstring,然后使用L字符串连接

时间:2014-02-14 01:25:32

标签: c++

采取以下措施:

highestScore->Data( ) // wchar_t *Platform::String::Data     
startMenuItems.push_back( L"Highest score: " ); // startMenu is an array of wstring

如何执行以下操作?

startMenuItems.push_back( L"Highest score: " + highestScore->Data( ) );

我收到以下错误:

Error no operator "+" matches these operands
operand types are: const wchar_t[16] and const wchar_t*

最终会在这里使用:

virtual HRESULT CreateTextLayout(
  [in]   const WCHAR * string,
  UINT32  stringLength,
  IDWriteTextFormat * textFormat,
  FLOAT  maxWidth,
  FLOAT  maxHeight,
  [out]  IDWriteTextLayout ** textLayout
) = 0;

表示第一个参数...

1 个答案:

答案 0 :(得分:3)

试试这个:

startMenuItems.push_back(
    std::wstring(L"Highest score: ") + highestScore->Data());

您需要#include <string>