我想重载后缀增量运算符作为一个类存储大数字作为一个整数的数组的成员函数。但它一直返回为0.任何提示为什么这不起作用?重载后缀增量运算符
这是一个家庭作业问题,所以我想要比直接代码更多的提示。谢谢。
成员的数据是这样的:
哪里currentSize是用于跟踪的阵列目前有多大是一个跟踪变量。
而且我的代码是:
负载的功能在阵列中把一个int在第一地点与其他人在移动的一切。
/* postfix*/
NewInt& NewInt::operator++(int nothing)
{
int count = 1;
largeInt[currentSize - count] += 1;
while(largeInt[currentSize - count] > 9)
{
if(currentSize - count - 1 < 0)
{
firstVar = true;
Load(1);
}
else
largeInt[currentSize - count - 1] += 1;
count++;
}
return *this;
}
你显示LargeInt,但实际的代码使用'数字'。是数字引用LargeInt – Chubsdad 2010-11-09 03:46:28
不命名operator ++的参数;这是一个最佳实践 – Chubsdad 2010-11-09 03:48:22
是的,我把它改成了largeInt,它在我的程序中是正确的,只是有点累,从测试程序复制和粘贴。固定。 – dubyaa 2010-11-09 03:51:25