【发布时间】:2015-05-19 16:14:25
【问题描述】:
我有一个具有以下构造函数的类:
Color(const float red = 0.0f, const float green = 0.0f, const float blue = 0.0f, const float alpha = 1.0f);
Color(const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha);
Color(const unsigned long int color);
如果我这样称呼它:
Color c{ 0.0f, 1.0f, 0.0f, 1.0f };
一切正常。但如果我称之为:
Color c{ 78, 180, 84, 255 };
或
Color c{ 0xffffffff };
我收到
错误 C2668: 'Color::Color' : 对重载函数的模糊调用
为什么?如何让它正确选择?
【问题讨论】:
标签: c++ overloading