MFC的类型强制转换问题?
MFX深入浅出有这么一段: struct AFX_MSGMAP_ENTRY;
struct AFX_MSGMAP{
AFX_MSGMAP* pBaseMessageMap;
AFX_MSGMAP_ENTRY* lpEntries;
};
#define DECLARE_MESSAGE_MAP()
static AFX_MSGMAP_ENTRY _messageEntries[];
static AFX_MSGMAP messageMap;
virtual AFX_MSGMAP* GetMessageMap() const;
#define BEGIN_MESSAGE_MAP(theClass,baseClass)
AFX_MSGMAP* theClass::GetMessageMap() const{
return &theClass::messageMap
}
AFX_MSGMAP theClass::messageMap={
&(baseClass::messageMap),
(AFX_MSGMAP_ENTRY*) &(TheClass::_messageEntries)}
提问:
(AFX_MSGMAP_ENTRY*) &(TheClass::_messageEntries)这里干嘛弄个(AFX_MSGMAP_ENTRY*) &转换,为何不直接用TheClass::_messageEntries,如:
AFX_MSGMAP theClass::messageMap={
&(baseClass::messageMap),
TheClass::_messageEntries} .
比如:
int *p;
int a[]={1};
p=a就可以了,照上面说的,
AFX_MSGMAP_ENTRY* lpEntries
AFX_MSGMAP_ENTRY _messageEntries[];
lpEntries=(AFX_MSGMAP_ENTRY*) &(TheClass::_messageEntries).
难道要p=(int*)&a,为何这样定义。