Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 按照第一个hello world示例在VS2010中获取编译错误_C++_Visual Studio 2010_Mfc_Compiler Errors_Visual C++ 2010 - Fatal编程技术网

C++ 按照第一个hello world示例在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

我刚开始学习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 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教程吗