变量周围的堆栈已损坏
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
}
它在 return 语句上给了我一个错误,说"运行时检查失败 #2 - 变量'结果'周围的堆栈已损坏。
我看不出该功能有什么问题。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
,但你正在写三个。
相关文章:
- gdb错误:Backtrace已停止:上一帧与此帧相同(堆栈已损坏?)
- 变量周围的堆栈'...'已损坏
- 运行时检查失败 #2 变量"A"周围的堆栈已损坏
- 运行时检查失败 #2 - 变量"e"周围的堆栈已损坏。发生
- 变量周围的堆栈'sortArray'已损坏
- 变量周围的堆栈'folderPath'已损坏
- 运行时检查失败 #2 - 变量周围的堆栈'...'已损坏
- 运行时检查失败 #2 - 变量"l1"周围的堆栈已损坏
- C++:此代码可以编译,但引发运行时检查失败 #2 - 围绕变量周围的堆栈'num'已损坏。发生
- 数组变量周围的堆栈已损坏
- 运行时检查失败 - 变量周围的堆栈已损坏
- 调试:运行时检查失败 #2 - 变量"LoggerThread"周围的堆栈已损坏
- 运行时检查失败 #2 - 变量周围的堆栈'k'已损坏
- 运行时检查失败 #2 - 变量"数字选择"周围的堆栈已损坏
- 数组问题:变量周围的堆栈'arr'已损坏
- 运行时间检查:变量周围的堆栈已损坏
- 变量周围的堆栈'Yarray'已损坏
- 变量"name"周围的堆栈已损坏C++
- 运行时检查失败#2 - 变量周围的堆栈'myArray'已损坏.- 似乎无法弄清楚如何删除此错误
- MS 工作室 17 变量周围的堆栈已损坏