如果这是一个骗局,我深表歉意。我发现了很多帖子。防止隐式转换,但没有任何意义。鼓励隐式构造。
如果我有:
class Rect
{
public:
Rect( float x1, float y1, float x2, float y2){};
};
和免费功能:
Rect Scale( const Rect & );
为什么会
Rect s = Scale( 137.0f, 68.0f, 235.0f, 156.0f );
不进行 const Rect&
的隐式构造,而是生成此编译器错误
'Scale' : function does not take 4 arguments
最佳答案
因为语言不支持这个特性。你必须写
Rect s = Scale(Rect(137.0f, 68.0f, 235.0f, 156.0f));
关于c++ - 我必须将哪些参数传递给函数才能执行对象的隐式构造?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4105539/