|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
为啥我我输入下面代码,会提示以下错误:
代码:
- #include"strsafe.h"
- #include<windows.h>
- #include<iostream>
- #include<string>
- using namespace std;
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- int res;
- int count = 0;
- TCHAR pszDest[30];
- size_t cchDest = 30;
- LPCTSTR pszFormat = TEXT("你总共点击了 %f 次");
- while (true)
- {
- res = MessageBox(NULL, TEXT("test window"), TEXT("是否关闭?"), MB_YESNO | MB_ICONINFORMATION);
- if (res == IDYES)
- count++;
- else
- break;
- }
- LPCWSTR out = TEXT("你总共点击了" + to_string(count) + "次");
- MessageBox(NULL, TEXT("end"), out, MB_OK | MB_ICONINFORMATION);
- return 0;
- }
复制代码
错误信息:
- 没有与这些操作数匹配的 "+" 运算符
- 操作数类型为: const wchar_t [7] + std::string
复制代码
string库不是有"+"操作符吗?
- #include"strsafe.h"
- #include<windows.h>
- #include<iostream>
- #include<string>
- using namespace std;
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- int res;
- int count = 0;
- TCHAR pszDest[30];
- size_t cchDest = 30;
- LPCTSTR pszFormat = TEXT("你总共点击了 %f 次");
- while (true)
- {
- res = MessageBox(NULL, TEXT("test window"), TEXT("是否关闭?"), MB_YESNO | MB_ICONINFORMATION);
- if (res == IDYES)
- count++;
- else
- break;
- }
- LPCWSTR out = (L"你总共点击了" + to_wstring(count) + L"次").c_str();
- MessageBox(NULL, TEXT("end"), out, MB_OK | MB_ICONINFORMATION);
- return 0;
- }
复制代码
|
|