[英]Stack around variable is corrupted
我知道這個主題有很多問題,但是它們似乎都是特定於代碼的。
我有這個功能-
Point2 ITCS4120::operator* (const Matrix3x3& m, const Point2& p) {
Point2 result;
for(int i=0;i<3;i++) {
result[i] = (m[i][0]*p[0]) + (m[i][1]*p[1]) + (m[i][2]);
}
return result; //error here
}
它在返回語句中給我一個錯誤,提示“運行時檢查失敗#2-變量'result'周圍的堆棧已損壞”。
我看不到該功能有什么問題。 Matrix3x3的數組只是-
float array[3][3];
而Point2的數組是
float array [2];
Matrix3x3和Point2類都具有以下代碼-
/** Write access for element in row [i] */
inline Scalar* operator[](int i) {return array[i];}
/** Read access for element in row [i] */
inline const Scalar* operator[](int i)const {return array[i];}
這段代碼是給我的,我以前有一些功課要對點,矩陣和向量進行算術運算。 我的代碼通過了所有測試,因此我假設我的Point2 ITCS4120 :: operator *(const Matrix3x3&m,const Point2&p)代碼正確。 但是也許我需要不同地使用[]運算符?
看來您的觀點包含兩個float
但您正在寫三個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.