我无法在其他地方找到答案,所以我想我只需要问这个:我正在尝试获取向量的别名(其中存储了 int 指针),如下所示:
void conversion(Engine * ENGINES)
{//The Engine class has a vector of int* as a public data member called SITE
for (int i = 0; i < 3; i++)
{
vector <int*>* current = &(ENGINES[i].SITE);//the problematic line
int j_max = current -> size();
cout << j_max << endl;
for (int j = 0; j < j_max; j++)
{
for (int k = 0; k < 3; k++)
{
if (*current[j][k] == 2)
*current[j][k] = 1;
if (*current[j][k] == -1)
*current[j][k] = 0;
}
}
}
}
问题是 *current[a][b] 的索引似乎有反转。我希望能够将 current 用作法线向量,但现在与以下相比,索引是相反的:
vector <int*> current1 = ENGINES[1].SITE;
所以*current[i][j] = current1[j][i]
出于某种原因。我的语法有错误吗?