我正在努力解决这个访问违规写入位置。
我有两个班级:
第一个 -
class_A
{
private:
struct Complex
{
float time;
vector<vector<float>> matrix;
};
Complex m_tempStruct;
ConnectivityMatrix* p_ConnMatrix; //pointer to the second class
void functionOfClass_A()
{
...
p_ConnMatrix->functionOfClass_ConnectivityMatrix(m_tempStruct.time, &m_tempStruct.matrix); //sending float and a pointer to vector<vector<float>>
...
}
};
第二个 -
class ConnectivityMatrix
{
private:
struct Complex
{
float time;
vector<vector<float>> matrix;
};
Complex m_tempStruct;
vector<Complex> m_mainVectorConnectivity;
public:
void functionOfClass_ConnectivityMatrix(float time, vector<vector<float>>* matrix)
{
...
m_tempStruct.time = time; // <--- crashes here
m_tempStruct.matrix = *matrix;
m_mainVectorConnectivity.push_back(m_tempStruct);
...
}
};
我可以看到time
包含浮点值,matrix
包含浮点数的两维向量。但是当我尝试在m_tempStruct.time
我很乐意为你提供帮助。
感谢。