【发布时间】:2012-09-03 16:42:55
【问题描述】:
在阅读 C++ 中的位图处理时,我遇到了这段代码 用于使用从位图文件中获取的数据加载调色板:
//set Number of Colors
numColors = 1 << bmih.biBitCount;
//load the palette for 8 bits per pixel
if(bmih.biBitCount == 8) {
colours=new RGBQUAD[numColours];
fread(colours,sizeof(RGBQUAD),numColours,in);
}
其中“bmih.biBitCount”是一个已经有值的预定义变量。 为什么作者声明 numColors 等于 1 然后将值 bmih.biBitCount 分配给同一行中的该变量?这到底是做什么的?像这样为变量赋值两次有什么好处?
【问题讨论】:
-
1 没有像你想的那样分配给
numColors -
你真的需要一本 C++ 入门书
标签: c++ variables syntax bitmap inline