Reputation: 1827
What am I doing wrong here? The compiler tells me it is a syntax error.
class Color {
private:
float rgba[4];
public:
Color(float red, float green, float blue, float alpha=1.0):
this->rgba[0] (red * alpha),
this->rgba[1] (green*alpha)
this->rgba[2] (blue*alpha)
{
}
};
Upvotes: 0
Views: 63
Reputation: 86
You can use the asigment operator instead of parentetheses:
this->rgba[0](red * alpha) // wrong
this->rgba[1] = red * alpha // ok
Upvotes: 0
Reputation: 217085
It should be
Color(float red, float green, float blue, float alpha=1.0):
rgba{red * alpha, green*alpha, blue*alpha, 0}
{
}
Upvotes: 4