Home > Back-end >  Questions about the overloading!!!!!!!!!!
Questions about the overloading!!!!!!!!!!

Time:09-25

Help me and explain the cause of the error, how to fix it
# include
using namespace std;
The class zerotwo
{
Public:
Zerotwo ()
{
I=1;
}
Zerotwo operator * (zerotwo& Right)
{
Zerotwo temp.
Temp. I=I * right. I;
return temp;
}
Zerotwo operator=(zerotwo& Right)
{
I=right. I;
}
int i;
};
Int main ()
{
Zerotwo p1.
Zerotwo p2.
P1=p * (p2); "-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
wrong here}

CodePudding user response:

Parameters such as const T&
Opertor=return references rather than values
Use return * this;

CodePudding user response:

reference 1/f, the truth is more important than right or wrong response:
parameters such as const T&
Opertor=return references rather than values
Use return * this;

I know this, I just want to know why can't write

CodePudding user response:

reference 1/f, the truth is more important than right or wrong response:
parameters such as const T&
Opertor=return references rather than values
Use return * this;

I know. Thanks
  • Related