使用重载运算符计算两个类
重载操作 +
构造函数
假设输出:
b= + 8 * x^3 + 6 * x^2 + 4 * x + 2;
c= + 3 * x^2 + 1;
d= + 8 * x^3 + 9 * x^2 + 4 * x + 3
我尝试在重载函数内使用 for
循环 +
将两个Polynomial
类相加。但重载功能不起作用。
d
应该是 b
和 c
相加的函数。
Overload op +
Constructor
Supposed output:
b= + 8 * x^3 + 6 * x^2 + 4 * x + 2;
c= + 3 * x^2 + 1;
d= + 8 * x^3 + 9 * x^2 + 4 * x + 3
I try to use a for
loop inside the overload function +
to add the two Polynomial
classes up. But the overload function does not work.
The d
is supposed to be a function that b
and c
add up to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论