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

,就写了个简单的COM 接口类就出现N多个异常

2013-11-09 
救命啊,就写了个简单的COM 接口类就出现N多个错误本人初学COM,对c++也不是很了解,只能说接触过,一直用C#开

救命啊,就写了个简单的COM 接口类就出现N多个错误
本人初学COM,对c++也不是很了解,只能说接触过,一直用C#开发的
就照着书写了接口类就出现N多个错误,求助大侠啊

#pragma once

class IMyUnknown
{
public:
virtual HRESULT _stdcall QueryInterface(const IID& iid, void * *ppv) = 0;
virtual ULONG   _stdcall AddRef() = 0;
virtual ULONG   _stdcall Release() =0;
};

错误信息:
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2143: syntax error : missing ';' before '__stdcall'
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2433: 'HRESULT' : 'virtual' not permitted on data declarations
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2501: 'HRESULT' : missing storage-class or type specifiers
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2143: syntax error : missing ',' before '&'
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2059: syntax error : '&'
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2253: 'QueryInterface' : pure specifier only applies to virtual function - specifier ignored
e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2143: syntax error : missing ';' before '__stdcall'
e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2433: 'ULONG' : 'virtual' not permitted on data declarations
e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2501: 'ULONG' : missing storage-class or type specifiers
e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2253: 'AddRef' : pure specifier only applies to virtual function - specifier ignored
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2143: syntax error : missing ';' before '__stdcall'
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2433: 'ULONG' : 'virtual' not permitted on data declarations
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2501: 'ULONG' : missing storage-class or type specifiers
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2253: 'Release' : pure specifier only applies to virtual function - specifier ignored

当然说白了这个3处错误都是同样的错误,但是本人愚钝就是找不出来
[解决办法]
是不是键工程建错了
[解决办法]
参考http://www.vckbase.com/index.php/wv/1547.html

引用:
本人初学COM,对c++也不是很了解,只能说接触过,一直用C#开发的
就照着书写了接口类就出现N多个错误,求助大侠啊

#pragma once

class IMyUnknown
{
public:
virtual HRESULT _stdcall QueryInterface(const IID& iid, void * *ppv) = 0;
virtual ULONG   _stdcall AddRef() = 0;
virtual ULONG   _stdcall Release() =0;
};

错误信息:
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2143: syntax error : missing ';' before '__stdcall'
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2433: 'HRESULT' : 'virtual' not permitted on data declarations
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2501: 'HRESULT' : missing storage-class or type specifiers
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2143: syntax error : missing ',' before '&'
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2059: syntax error : '&'
e:\work project\test project\com\dictcomp\imyunknown.h(6) : error C2253: 'QueryInterface' : pure specifier only applies to virtual function - specifier ignored
e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2143: syntax error : missing ';' before '__stdcall'
e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2433: 'ULONG' : 'virtual' not permitted on data declarations
e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2501: 'ULONG' : missing storage-class or type specifiers


e:\work project\test project\com\dictcomp\imyunknown.h(7) : error C2253: 'AddRef' : pure specifier only applies to virtual function - specifier ignored
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2143: syntax error : missing ';' before '__stdcall'
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2433: 'ULONG' : 'virtual' not permitted on data declarations
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2501: 'ULONG' : missing storage-class or type specifiers
e:\work project\test project\com\dictcomp\imyunknown.h(8) : error C2253: 'Release' : pure specifier only applies to virtual function - specifier ignored

当然说白了这个3处错误都是同样的错误,但是本人愚钝就是找不出来

热点排行