GGRUNDY
asked on
user defined assignment
I would love to have a user defined copy function
like this one.
void operator=(RGBQUAD& q, PALETTEENTRY& pe)
{
q.rgbRed = pe.peRed;
q.rgbGreen = pe.peGreen;
q.rgbBlue = pe.peBlue;
q.rgbReserved = 0;
}
but to compiler tells me to bugger off.
Is "void Copy(RGBQUAD& q, PALETTEENTRY& pe)"
my only option? Thanks.
like this one.
void operator=(RGBQUAD& q, PALETTEENTRY& pe)
{
q.rgbRed = pe.peRed;
q.rgbGreen = pe.peGreen;
q.rgbBlue = pe.peBlue;
q.rgbReserved = 0;
}
but to compiler tells me to bugger off.
Is "void Copy(RGBQUAD& q, PALETTEENTRY& pe)"
my only option? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys.
int &operator = (int l, int r);
int operator = (int l, double r);
which have already been defined by the language.
Note how Jason changed the return value of your function. This is not required, but it is a customary practice. by doing that you can "chain" assignments like
a = b = c;