VC中的 动态结构体

来源:互联网 发布:知乎课程 编辑:程序博客网 时间:2024/06/04 23:05

typedef struct ST_COLUMN
{
 CString csColName;
 CString csColValue;
}COLUMN;

 

typedef CArray<COLUMN,COLUMN&> ARG_ColValue;

 

ARG_ColValue g_argColValue;

----------------------------------------------------------------------------------------------------------------

 ST_COLUMN stCol;
 stCol.csColName="id1";
 stCol.csColValue="10001";
 g_argColValue.Add(stCol);

 

 int iCont=g_argColValue.GetCount();

 

 stCol.csColName="id2";
 stCol.csColValue="10002";
 g_argColValue.Add(stCol);

 iCont=g_argColValue.GetCount();
 
 stCol.csColName="id3";
 stCol.csColValue="";
 g_argColValue.Add(stCol);

 iCont=g_argColValue.GetCount();
 
 for(int i=0; i<iCont; i++)
 {
  stCol=g_argColValue.GetAt(i);
  CString csValue1 = stCol.csColName;
  CString csValue2 = stCol.csColValue;
 }


 for(int i=0; i<iCont; i++)
 {
  stCol=g_argColValue.GetAt(i);
  if(stCol.csColName == "id3")
  {
   stCol.csColValue="100003";
   g_argColValue.SetAt(i,stCol);
  }
 }
 
 for(int i=0; i<iCont; i++)
 {
  stCol=g_argColValue.GetAt(i);
  CString csValue1 = stCol.csColName;
  CString csValue2 = stCol.csColValue;
 }

 

 g_argColValue.RemoveAt(1);
 iCont=g_argColValue.GetCount();


 for(int i=0; i<iCont; i++)
 {
  stCol=g_argColValue.GetAt(i);
  CString csValue1 = stCol.csColName;
  CString csValue2 = stCol.csColValue;
 }

 

 g_argColValue.RemoveAll();
 iCont=g_argColValue.GetCount();


 for(int i=0; i<iCont; i++)
 {
  stCol=g_argColValue.GetAt(i);
  CString csValue1 = stCol.csColName;
  CString csValue2 = stCol.csColValue;
 }

原创粉丝点击