I have a class Color that contains three float components (r, g, b).
I have to program the following function :
Color getColor(unsigned char values[], int i)
Normally I should program it like this :
Color getColor(unsigned char values[], int i){
return Color((float) values[i]/255.0, (float) values[i+1]/255.0, (float) values[i+2]/255.0);
}
But by error I did
return values[i];
When I compiled I didn't get any compilation error and I haven't get run time error either.
Why this is possible?
This could be a result of non-explicit constructor of Color class accepting unsigned char as its argument.
That means you have constructor in Color class with single argument OR multiple arguments rest being default parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With