首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

请问达人:com编程,编译报错

2012-03-27 
请教达人:com编程,编译报错《com技术内幕》书本上示例,代码如下://// Iface.cpp// To compile, use: cl Ifac

请教达人:com编程,编译报错
《com技术内幕》书本上示例,代码如下:

//
// Iface.cpp
// To compile, use: cl Iface.cpp
//
#include <iostream.h>
#include <objbase.h> // Define interface.

void trace(const char* pMsg) {cout << pMsg << endl ;}

// Abstract interfaces
interface IX
{
virtual void __stdcall Fx1() = 0 ;
virtual void __stdcall Fx2() = 0 ;
} ;

interface IY
{
virtual void __stdcall Fy1() = 0 ;
virtual void __stdcall Fy2() = 0 ;
} ;

// Interface implementation
class CA : public IX, 
  public IY
{
public:

// Implement interface IX.
virtual void __stdcall Fx1() {cout << "CA::Fx1" << endl ;}
virtual void __stdcall Fx2() {cout << "CA::Fx2" << endl ;}

// Implement interface IY.
virtual void __stdcall Fy1() {cout << "CA::Fy1" << endl ;}
virtual void __stdcall Fy2() {cout << "CA::Fy2" << endl ;}

} ;


// Client
int main()
{
trace("Client: Create an instance of the component.") ;
CA* pA = new CA ;

// Get an IX pointer.
IX* pIX = pA ;

trace("Client: Use the IX interface.") ;
pIX->Fx1() ;
pIX->Fx2() ;

// Get an IY pointer.
IY* pIY = pA ;

trace("Client: Use the IY interface.") ;
pIY->Fy1() ;
pIY->Fy2() ;

trace("Client: Delete the component.") ;
delete pA ;

return 0 ;
}

编译时报错,如下:
--------------------Configuration: IFACE - Win32 Debug--------------------
Compiling...
IFACE.CPP
c:\program files\microsoft visual studio\vc98\include\winuser.h(45) : error C2146: syntax error : missing ';' before identifier 'MENUTEMPLATE'
c:\program files\microsoft visual studio\vc98\include\winuser.h(45) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

IFACE.exe - 2 error(s), 0 warning(s)

定位错误,在头文件《winuser.h》中:
//typedef HANDLE HDWP;
//typedef VOID MENUTEMPLATEA;
//typedef VOID MENUTEMPLATEW;
#ifdef UNICODE
typedef MENUTEMPLATEW MENUTEMPLATE;
#else
typedef MENUTEMPLATEA MENUTEMPLATE;
#endif // UNICODE

请达人给予帮助,谢谢!


[解决办法]
没有错误呀?

热点排行