yiteeee 2017-06-28 00:36 采纳率: 33.3%
浏览 1058

老师布置作业读代码,这个头文件实在读不懂了

#define DECLARE_MESSAGE_MAP() \
protected: \
static const AFX_MSGMAP* GetThisMessageMap(); \
virtual const AFX_MSGMAP* GetMessageMap() const; \

#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return GetThisMessageMap(); } \
const AFX_MSGMAP* theClass::GetThisMessageMap() \
{ \
typedef theClass ThisClass; \
typedef baseClass TheBaseClass; \
static const AFX_MSGMAP_ENTRY _messageEntries[] = \
{

#define END_MESSAGE_MAP() \
{0,(AFX_PMSG)0 } \
}; \
static const AFX_MSGMAP messageMap = \
{ &TheBaseClass::GetThisMessageMap, &_messageEntries[0] }; \
return &messageMap; \
}

#define ON_COMMAND(id, memberFxn) \
{ id, static_cast (memberFxn) },

这是C++的代码头文件中的一部分,希望大佬们帮我解释一下,不懂define啊


如果需要 我把剩余三个头文件粘贴在这里:
//Base.h
#pragma once

#include
#include "test.h"

using namespace std;

class CBase;

typedef void (CBase::*AFX_PMSG)(void);

struct AFX_MSGMAP_ENTRY
{
int nMessage; // windows message

AFX_PMSG pfn;    // routine to call (or special value)

};

struct AFX_MSGMAP
{
const AFX_MSGMAP* (* pfnGetBaseMap)();
const AFX_MSGMAP_ENTRY* lpEntries;
};

class CBase
{
public:
CBase(void);
~CBase(void);

const AFX_MSGMAP_ENTRY* pMsgEntry;
AFX_PMSG pVIBaseMemFunc;
int  messageid;
void GetMessage();
void DisPatchMessage();
virtual void initInstance();

DECLARE_MESSAGE_MAP()

};

//Current.h
#pragma once
#include "base.h"

class CCurrent :
public CBase
{
public:
CCurrent(void);
~CCurrent(void);
virtual void initInstance();
void coutid2();
void coutid4();
void coutid6();
void coutid8();
DECLARE_MESSAGE_MAP()
};

//Drived.h
#pragma once
#include "current.h"

class CDrived :
public CCurrent
{
public:
CDrived(void);
~CDrived(void);
virtual void initInstance();

void coutid1();
void coutid3();
void coutid5();
void coutid7();

DECLARE_MESSAGE_MAP()

};

  • 写回答

2条回答 默认 最新

  • 西可我偏偏是这款 2017-06-28 02:36
    关注

    定义了消息映射啊,头文件里没有注释怎么看得懂cpp里都实现了什么啊?

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?