在這裏得到了一些代碼給我一個運行時錯誤,我似乎無法修復。函數Length()計算點數組中所有點之間的累積距離。它使用一個先前定義的函數Distance(),我知道它完美地工作。任何指針?運行時錯誤問題
這裏是功能我的源代碼:
template<typename Point> //Length function
double PointArray<Point>::Length() const
{
double total_length = 0;
for (int i=0; i<Size(); i++)
{
total_length += (GetElement(i)).Distance(GetElement(i+1));
}
return total_length;
}
這裏是我的實現:
cout<<"The Length of the Point Array is: "<<(*ptArray1).Length()<<endl;
非常感謝!
哇。永遠不會想到這一點。非常感激! – Byron 2013-04-23 13:30:28