C++ 按照第一个hello world示例在VS2010中获取编译错误
我刚开始学习MFC..在这里找到了一个教程..在VS2010中尝试了同样的方法,但是在这段代码中得到了一个编译错误C++ 按照第一个hello world示例在VS2010中获取编译错误,c++,visual-studio-2010,mfc,compiler-errors,visual-c++-2010,C++,Visual Studio 2010,Mfc,Compiler Errors,Visual C++ 2010,我刚开始学习MFC..在这里找到了一个教程..在VS2010中尝试了同样的方法,但是在这段代码中得到了一个编译错误 void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting dc.TextOut(0, 0, "Hello, world!"); // TODO: Add your message handler code here // Do not cal
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.TextOut(0, 0, "Hello, world!");
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
}
错误是:
错误C2664:'BOOL CDC::textouth(int,int,const CString&'):无法将参数3从'const char[14]'转换为'const CString&
'
有人能解决这个问题并推荐一些mfc教程吗..谢谢..问题是Windows默认使用宽字符
wchar\t
作为文本。你需要
dc.TextOut(0, 0, L"Hello, world!");
问题是Windows默认使用宽字符
wchar\t
作为文本。你需要
dc.TextOut(0, 0, L"Hello, world!");
这个错误告诉你什么是完全错误的
error C2664: 'BOOL CDC::TextOutW(int,int,const CString &)' : cannot convert parameter 3 from 'const char [14]' to 'const CString &'
textowu()
应将const CString&
作为第三个参数,您正在传递const char[14]
您需要执行以下操作:
dc.TextOut(0, 0, L"Hello, world!");
它以函数所需的格式传递第三个参数
要查看MFC参考资料,请参见。错误会告诉您到底出了什么问题
error C2664: 'BOOL CDC::TextOutW(int,int,const CString &)' : cannot convert parameter 3 from 'const char [14]' to 'const CString &'
textowu()
应将const CString&
作为第三个参数,您正在传递const char[14]
您需要执行以下操作:
dc.TextOut(0, 0, L"Hello, world!");
它以函数所需的格式传递第三个参数
如需MFC参考资料,请参阅。非常感谢。您能为初学者推荐一些好的MFC教程吗?非常感谢。您能为初学者推荐一些好的MFC教程吗