1.Vector
typedef struct tagBTNPICINFO
{
DWORD picID;
UINT LeftPos;
UINT topPos;
UINT width;
UINT height;
} BTNPICINFO;
vector<BTNPICINFO>bnt;//test vector
//vector<BTNPICINFO>bnt(6);//test vector
for (int i=0; i<6;i++)
{
BTNPICINFO test;
test.picID = i;
test.LeftPos = i;
test.topPos = i;
test.width = i;
test.height = i;
bnt.push_back(test);
}
UINT ht0 = bnt[0].height;//test vector//0
UINT ht1 = bnt[1].height;//1
UINT ht2 = bnt[2].height;//2
UINT ht3 = bnt[3].height;//3
UINT ht4 = bnt[4].height;//4
UINT ht5 = bnt[5].height; //5
如果把用vector<BTNPICINFO>bnt(6);//test vector
的话 输出的高将是0,因为bnt(6)这里已经默认被初始化为0了,push_back(test)是往后面放元素的,所以后面的元素才会6,7,8,9,。。。才开始有需要的数据!