CNET中国旗舰网站

ZDNet China | CNET科技资讯网 | 政府采购 | 行业网站联盟




 
标题: [求助] 宏定义报错为哪般?
李小璐
白金会员
Rank: 7Rank: 7Rank: 7



UID 324328
精华 0
积分 4520
帖子 501
威望 2074
ZD币 644 元
阅读权限 150
注册 2008-5-5
状态 离线
  楼主
发表于 2008-6-13 14:05  资料  个人空间  短消息  加为好友 
开发者在线

宏定义报错为哪般?

C/C++ code #include<iostream>#include<windows.h>
using
namespace std;/*仿cruntimeclass的宏定义*/
struct runtime{public:    LPCSTR m_lpszclassname;    static runtime* mfirstclass;            runtime* m_pnextclass;     runtime* m_pbaseclass; };#define DECLARE_DYNAMIC(class_name) \
public:\static runtime class##class_name;\virtual runtime* getruntimeclass(); #define _IMPLEMENT_RUNTIMECLASS(class_name,base_class_name)\runtime* class_name::getruntimeclass();\{return
&class_name::class##class_name;}\    static
char _lpszCView[] = #class_name;\    class_name::class##class_name.m_lpszclassname = _lpszCView;#define _IMPLEMENT_DYNAMIC(class_name,base_class_name)\   _IMPLEMENT_RUNTIMECLASS(class_name,base_class_name)class a{public:    a(){}    };class b:public a{public:    DECLARE_DYNAMIC(b)};_IMPLEMENT_DYNAMIC(b,a)int main(){        return
0;}/*C:\Program Files\Microsoft Visual Studio\MyProjects\cruntimeclas\hong.cpp(46) : error C2447: missing function header (old-style formal list?)C:\Program Files\Microsoft Visual Studio\MyProjects\cruntimeclas\hong.cpp(46) : error C2143: syntax error : missing ';' before '.'C:\Program Files\Microsoft Visual Studio\MyProjects\cruntimeclas\hong.cpp(46) : error C2501: 'classb' : missing storage-class or type specifiersC:\Program Files\Microsoft Visual Studio\MyProjects\cruntimeclas\hong.cpp(46) : error C2371: 'public: static struct runtime b::classb' : redefinition; different basic types        C:\Program Files\Microsoft Visual Studio\MyProjects\cruntimeclas\hong.cpp(43) : see declaration of 'public: static struct runtime b::classb'C:\Program Files\Microsoft Visual Studio\MyProjects\cruntimeclas\hong.cpp(46) : error C2143: syntax error : missing ';' before '.'执行 cl.exe 时出错.*/




顶部
 



当前时区 GMT+8, 现在时间是 2009-7-4 23:24

  Powered by Discuz! 5.5.0 © 2001-2007 Comsenz Inc.
Processed in 0.070785 second(s), 3/3 queries

清除 Cookies - 联系我们 - ZDNetChina中文社区 - 无图版