You didn’t specify the types, so I’m going to assume that these are all builtin C++ types, specifically arithmetic types (either integer type or a floating point type). If it is a user defined type, I can’t guarantee that anything I say below still applies.
T& lhs.operator=(T& rhs)
is the copy assignment operator (it could also be a move assignment, but not in this case). The (canonical) copy assignment operator takes a reference to the rhs
as a parameter, copies the data into the lhs
, and returns a reference to lfs
.
T& lhs.operator++(int)
is the increment operator (note the int
, this is what separates a postfix from a prefix increment operator). While T&
is the canonical return type for most builtin types, it is common for user defined types to return T
. Either way, the postfix increment operator increases the value of lhs
but returns the original value.
T& lhs.operator+=(T& rhs)
is the compound addition assignment operator. It is equivalent to the expression lhs=lhs+rhs
except that lhs
gets evaluated only once.
So the equivalent not confusing code to
Out[i] = (Sum += Tap[TapPtr++] = Inp[i]);
would be
{
auto tempTapPtr=TapPtr;
++TapPtr;
Tap[tempTapPtr]=Inp[i];
Sum+=Tap[tempTapPtr];
}
Out[i]=Sum;
As you can see, the correct last line in your Java code should be Out[i]=Sum;
but unless the types are not the builtin arithmetic types, the Out[i]=Inp[i]
is functionally equivalent. Also, the second line of your Java code is incorrect. It should be Sum=Sum+Tap[TapPtr-1];
but like with the last line, is functionally equivalent to what you wrote.
2
solved Bizarre C++ code, trying to decipher