int Red = this->convert_Red + other.convert_Red;
int Green = this->convert_Green + other.convert_Green;
int Blue = this->convert_Blue + other.convert_Blue;
ostringstream str;
string name;
str << Red << Green << Blue;
You don't tell the interface of HexColour, so we don't tell where you have lost yourself.
name will contain decimal stuff. If the constructor expects hex, then you should tell the stream to make hex.
It could be convenient to construct a HexColour from integer components rather than string.
Is it logical to add colours like that? Let say, I have almost black -- each component is 0x01 (assuming 0xff is max). Add that colour a thousand times and each component becomes 0x3e8, which is way brighter than pure white.
As you can see I already converted them into integers.So I am trying to add them and then after convert them back to hexadecimal.Please help.I am clearly missing something
Your HexColour has the three integers. Would it not be more efficient to operate primarily with the integers and produce the string only when necessary?
If 55+FF must equal FF, then you need to clamp the result to FF. c = (a + b) % 256;