如何建立元素是struct数组的数组?高手帮忙!我建立了一个struct
typedef struct tagGridItem{
    CString value;
int nRow;
int nCol;
} GridItem;然后定义了一个struct数组:
CArray<GridItem, GridItem> m_ItemList;我想在建立一个数组,通俗点讲,这个数组里有三个元素,每个元素是一个struct数组,并需要每个struct数组的size不一样?我该怎么做呀?高手帮帮我呀?

解决方案 »

  1.   

    定义一个struct指针数组,每个元素是动态申请的一个struct数组
      

  2.   

    定义一struct指针数组,其中每个元素指向一个动态申请的struct数组
      

  3.   

    定义一struct指针数组,其中每个元素指向一个动态申请的struct数组
      

  4.   

    谢谢Lemon_2000(柠檬) !!!能详细点,或给点代码吗?xiexie
      

  5.   

    这都不知道,就是定义一个指针数组,数组中的每个元素即指针指向一个struct结构数组,得到大小后,new一下,分配相应的内存就行了
      

  6.   

    int size ;
    size = 你 要 得 大 小 
    GridItem m_ItemList = new GridItem[size]
      

  7.   

    应 该 是 这 样 
    int size ;
    size = 你 要 得 大 小 
    GridItem *m_ItemList = new GridItem[size]
      

  8.   

    typedef struct tagGridItem{
        CString value;
    int nRow;
    int nCol;
    } GridItem;typeddef CArray<GridItem, GridItem> ItemList;
    CArray<ItemList*,ItemList*> m_myArray;for(int i=0;i<3;i++)
    {
       ItemList* itemlLS = new ItemList;
       m_myArray[i] = itemlLS;
    }
      

  9.   

    struct aa{
       int a,
       int b
    };aa * xx[];这样每个xx[0] , xx[1]......都是一个struct aa *结构的变量了,在用这个指针完成你要的结构数据成员的内存分配等等功能.该给点分吧,哈哈。