结构体和类里面的成员地址是连续的吗?
今天我看到这样的写法
m_pDic=new unsigned char[m_Width*m_Height+sizeof(BITMAPINFOHEADER)+255*sizeof(RGBQUAD)]; m_pBih=(BITMAPINFOHEADER*)m_pDic; m_pBih->biWidth=m_Width; m_pBih->biHeight=m_Height; m_pBih->biBitCount=8; m_pBih->biClrImportant=0; m_pBih->biCompression=0; m_pBih->biClrUsed=256; m_pBih->biPlanes=1; m_pBih->biSize=40; unsigned char *pRGB=NULL; pRGB=m_pDic+sizeof(BITMAPINFOHEADER); for (int j=0;j<255;j++) { pRGB[4*j]=j; pRGB[4*j+1]=j; pRGB[4*j+2]=j; pRGB[4*j+3]=0; } m_pDibbits=m_pDic+sizeof(BITMAPINFOHEADER)+255*sizeof(RGBQUAD);