You could use a class hierarchy, such as:
class ColorPixel
{
public:
ColorPixel(int red, int green, int blue);
// whatever colors can do
Quote:
};
class ColorPixel15 : public ColorPixel
{
public:
ColorPixel15(int red, int green, int blue) : ColorPixel(red, green,
blue) { }
// whatever additional things ColorPixel15s can do
Quote:
};
class ColorPixel16 : public ColorPixel
{
public:
ColorPixel16(int red, int green, int blue) : ColorPixel(red, green,
blue) { }
// whatever additional things ColorPixel16s can do
Quote:
};
// somewhere off in code:
ColorPixel* pPixel = NULL;
if (ColorMode == 15)
pPixel = new ColorPixel 15;
else if (ColorMode == 16)
pPixel = new ColorPixel 16;
// etc.
Quote:
> //------------------------------------
> struct Color15bit{....};
> struct Color16bit{....};
> //------------------------------------
> if( ColorMode == 15 )
> typedef Color15bit Color16;
> else if( ColorMode == 16 )
> typedef Color16bit Color16;
> //----------------------------------
> Color16 aPixel(255, 255, 255 );
> //***********************************************//
> I know this is impossible
> How can I have same effect like that?