#include "stdafx.h"
#include "Console1.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// The one and only application objectCWinApp theApp;using namespace std;int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0; // initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
CString strHello;
strHello.LoadString(IDS_HELLO);
cout << (LPCTSTR)strHello << endl;
afxDump<<"abc"<<endl; //为什么这行错? } return nRetCode;
}error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)

解决方案 »

  1.   

    to : vccsdn
    没有用,错误一样
      

  2.   

    afxDump 不支持endl,去掉它就可以了.
      

  3.   

    主要原因还是 iostream 和 iostream.h 这两个头文件里面定义的endl不是一个东西
    afxDump << endl;1. 如果afxDump跟的是iostream.h的endl,没有关系,因为相当于afxDump << ostream&; 即输出ostream的地址,因此调用afxDump << (void*)ostream&,输出象这样:$102A2770
    2. 如果afxDump跟的是iostream的endl, 那就相当于把下面endl的定义带入,我也不知道什么结果:
    template<class _E, class _Tr> inline
    basic_ostream<_E, _Tr>&
    __cdecl endl(basic_ostream<_E, _Tr>& _O)
    {_O.put(_O.widen('\n'));
    _O.flush();
    return (_O); }