我有过
struct ArrayIndex
{
int rowIndex;
int columnIndex;
};
void fn()
{
vector<struct ArrayIndex> IntermediateIndex[2];
getNextRowColumn(&IntermediateIndex);
}
void getNextRowColumn(vector<ArrayIndex>* IntermediateIndex[2])
{
.................
}
它会给出错误cannot convert ‘std::vector<ArrayIndex> (*)[2]’ to ‘std::vector<ArrayIndex>**’ for argument ‘1’ to ‘void getNextRowColumn(std::vector<ArrayIndex>**)’
发布于 2018-06-18 02:12:21
我猜你想把C数组作为参数传递给一个函数,然后你需要类似这样的东西
void fn()
{
vector<ArrayIndex> IntermediateIndex[2];
getNextRowColumn(IntermediateIndex);
}
void getNextRowColumn(vector<ArrayIndex>* IntermediateIndex)
{
}
但是,由于问题是标记为C++
的,例如,您最好坚持使用C++语义
void fn()
{
array<vector<ArrayIndex>, 2> IntermediateIndex;
getNextRowColumn(IntermediateIndex);
}
void getNextRowColumn(array<vector<ArrayIndex>, 2>& IntermediateIndex)
{
}
或者使用vector<vector<…>>
,取决于你要用它做什么。
https://stackoverflow.com/questions/50899193
复制相似问题