且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

帮助重载c ++类运算符

更新时间:2023-11-10 08:44:40

会员12223678写道:

i没有实现+如果我做了我会用它+ =

这是我的问题我不知道如何实现+也没有+ =

如果你知道如何实现它请

帮助我因为我被卡住了
Member 12223678 wrote:
i didn't implement + either if i did i would have used it in +=
that is my problem i don't know how to implement + nor +=
please if you know how to implement it
help me because i'm stuck

也许你必须从

运算符重载 - cppreference.com [ ^ ],

C ++中的运算符重载 - Cprogramming.com [ ^ ]。



在上面引用的最后一篇文章中,最接近你的案例是Complex类的代码示例;显示+运算符的实现。



-SA

Perhaps you have to start with
operator overloading — cppreference.com[^],
Operator Overloading in C++ - Cprogramming.com[^].

In last of the articles referenced above, the case closest to yours is the code sample of class "Complex"; implementation of + operator is shown.

—SA