告别年代

阳光里闪耀的色彩真美丽

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

假定我们有两个头文件a.h和b.h,它们都定义了某个struct(或class):

// a.h
struct my_struct { ... };
// b.h
struct my_struct
{
   ...
};

现在我们需要b.h中的my_struct,但同时又需要这两个头文件的其他内容,我们可以这样做:

#define my_struct my_struct_a
#include "a.h"
#undef my_struct
#include "b.h"

 

posted on 2013-10-09 15:22  告别年代  阅读(1012)  评论(0编辑  收藏  举报