英雄无敌3hd中文版:c++中定义运算符一般用什么字母?

来源:百度文库 编辑:高校问答 时间:2024/05/09 07:40:21

给你一个例子看看吧:
Big_Int Big_Int::operator + (const Big_Int &second)
{
Big_Int second_ = second;
if(*this > 0 && second_ < 0)
return (*this - (-second_));
else if(*this < 0 && second_ > 0)
return (second_ - (-(*this)));
else
{
Big_Int current;
long carry, i;
for(carry = 0, i = L/4; i >=0; i --)
{
current.Int[i] = Int[i] + second.Int[i] + carry;
carry = current.Int[i] / 10000;
current.Int[i] = current.Int[i] % 10000;
}
current.digit = current.Digit();
return current;
}
}
这是重载的大数加运算的一段代码哈
给你一个例子看看吧:
Big_Int Big_Int::operator + (const Big_Int &second)
{
Big_Int second_ = second;
if(*this > 0 && second_ < 0)
return (*this - (-second_));
else if(*this < 0 && second_ > 0)
return (second_ - (-(*this)));
else
{
Big_Int current;
long carry, i;
for(carry = 0, i = L/4; i >=0; i --)
{
current.Int[i] = Int[i] + second.Int[i] + carry;
carry = current.Int[i] / 10000;
current.Int[i] = current.Int[i] % 10000;
}
current.digit = current.Digit();
return current;
}
}
这是重载的大数加运算的一段代码哈
给你一个例子看看吧:
Big_Int Big_Int::operator + (const Big_Int &second)
{
Big_Int second_ = second;
if(*this > 0 && second_ < 0)
return (*this - (-second_));
else if(*this < 0 && second_ > 0)
return (second_ - (-(*this)));
else
{
Big_Int current;
long carry, i;
for(carry = 0, i = L/4; i >=0; i --)
{
current.Int[i] = Int[i] + second.Int[i] + carry;
carry = current.Int[i] / 10000;
current.Int[i] = current.Int[i] % 10000;
}
current.digit = current.Digit();
return current;
}
}
这是重载的大数加运算的一段代码哈
给你一个例子看看吧:
Big_Int Big_Int::operator + (const Big_Int &second)
{
Big_Int second_ = second;
if(*this > 0 && second_ < 0)
return (*this - (-second_));
else if(*this < 0 && second_ > 0)
return (second_ - (-(*this)));
else
{
Big_Int current;
long carry, i;
for(carry = 0, i = L/4; i >=0; i --)
{
current.Int[i] = Int[i] + second.Int[i] + carry;
carry = current.Int[i] / 10000;
current.Int[i] = current.Int[i] % 10000;
}
current.digit = current.Digit();
return current;
}
}
这是重载的大数加运算的一段代码哈

给你一个例子看看吧:
Big_Int Big_Int::operator + (const Big_Int &second)
{
Big_Int second_ = second;
if(*this > 0 && second_ < 0)
return (*this - (-second_));
else if(*this < 0 && second_ > 0)
return (second_ - (-(*this)));
else
{
Big_Int current;
long carry, i;
for(carry = 0, i = L/4; i >=0; i --)
{
current.Int[i] = Int[i] + second.Int[i] + carry;
carry = current.Int[i] / 10000;
current.Int[i] = current.Int[i] % 10000;
}
current.digit = current.Digit();
return current;
}
}
这是重载的大数加运算的一段代码哈

operate 是关键字吧,然后加有ADD,减MIN,乘MUL,除DIV...