wcout 问题
#include <windows.h>
#include <tchar.h>
#include <iostream>
#include <winldap.h>
#include <iads.h>
#include <Adshlp.h>
int _tmain(int /* argc */, _TCHAR /* **argv */, _TCHAR /* **envp */)
{
IADs *pobjADs; // Pointer to object interface
BSTR bstrName; // String with object name
HRESULT hResult; // COM result code
// String to directory service
WCHAR *pstrADsPath =L"LDAP://ldap.itd.umich.edu/O=University of Michigan,C=us";
// Initalize COM
CoInitialize ( NULL );
// Get pointer to object's IADs interface
hResult = ADsGetObject( pstrADsPath, IID_IADs, (void**) &pobjADs);
// Check for success
if ( SUCCEEDED ( hResult ) )
{
// Get the Name property from the object
hResult = pobjADs->get_Name ( &bstrName );
// Check for success
if ( SUCCEEDED ( hResult ) )
{
// Display Name property
// (must use wide strings when working with COM)
wcout << L"The name of the object found is: "<< bstrName <<endl;
}
else
{
wcerr << L"Error occured while getting the object name: "
<< hResult << endl;
}
// When finished with the interface, call the
// Release method to free object
pobjADs->Release();
}
else
{
wcerr << L"Error occured while getting the object: "
<< hResult << endl;
}
// Unload COM
CoUninitialize ();
// Return the result of any failures
return hResult;
}
在vc6中调试结果如下:
eleting intermediate files and output files for project '2 - Win32 Debug'.
--------------------Configuration: 2 - Win32 Debug--------------------
Compiling...
2.cpp
d:\myprogram\2\2.cpp(35) : error C2065: 'wcout' : undeclared identifier
d:\myprogram\2\2.cpp(35) : error C2297: '<<' : illegal, right operand has type 'unsigned short [34]'
d:\myprogram\2\2.cpp(35) : error C2065: 'endl' : undeclared identifier
d:\myprogram\2\2.cpp(39) : error C2065: 'wcerr' : undeclared identifier
d:\myprogram\2\2.cpp(40) : error C2297: '<<' : illegal, right operand has type 'unsigned short [46]'
d:\myprogram\2\2.cpp(49) : error C2297: '<<' : illegal, right operand has type 'unsigned short [41]'
Error executing cl.exe.
2.exe - 6 error(s), 0 warning(s)
wout 不就在iostream中么?为什么说我未声明?