在深入浅出MFC中有这样的代码:
   struct MSGMAP_ENTRY _messageEntris[]=
{
    WM_CREATE,OnCreat,
    WM_SIZE,   OnSize,
    ……
}
请问struct不是定义结构用的吗?可是他这里定义的却是 数组。
   还有
   union MessageMapFunctions
{
  AFX_PMSG pfn;
 Bool   (AFX_MSG_CALL CWnd::*pfn_bD)(CDC*);
Bool   (AFX_MSG_CALL CWnd::*pfn_bD)(CDC*);
……
};
  说是一个函数的多种形式,是怎么回事,到底union是个什么东西?

解决方案 »

  1.   

    不会吧?
    1、结构体数组,没听说过吗?
    2、union是什么东西,问问自己到底有没有学过C?
      

  2.   

    union是联合,
    union的所有变量使用同一存贮空间,以最大的空间为准..
      

  3.   

    Unions are class types that can contain only one data element at a time (although the data element can be an array or a class type). The members of a union represent the kinds of data the union can contain. An object of union type requires enough storage to hold the largest member in its member-list.
      

  4.   

    1、
    struct MSGMAP_ENTRY _messageEntris[] //这里用的是纯C的申明方式,C中申明结构体时,在结构体名前必须加上struct。这儿就是定义MSGMAP_ENTRY结构体的数组,在C++中去掉struct也不会出错。2、union就是联合类型,表示多个不同类型的变量公用一个内存空间,MessageMapFunctions的定义里pfn,pfn_bD,其实都是同一个值的指针,只不过可以用不同的名称来按照不同的类型来引用而已。
      

  5.   

    谢谢了,我还有一个问题就是type-safe是什么意思?