我想重載後綴增量運算符作爲一個類存儲大數字作爲一個整數的數組的成員函數。但它一直返回爲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