我想通过重载 + 运算符来添加 2 个对象,但我的编译器说没有匹配的函数可以调用 point::point(int, int)。有人可以帮我处理这段代码并解释错误吗?谢谢你
#include <iostream>
using namespace std;
class point{
int x,y;
public:
point operator+ (point & first, point & second)
{
return point (first.x + second.x,first.y + second.y);
}
};
int main()
{
point lf (1,3)
point ls (4,5)
point el = lf + ls;
return 0;
}
原文由 Snowshoot 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以像这样更改代码,
希望这可以帮助…