首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >对于参数“1”到“std::vector<ArrayIndex>getNextRowColumn(std::vector<ArrayIndex>**)”,无法将“std::vector<ArrayIndex>(*)[2]”转换为“std::vector<ArrayIndex>**”

对于参数“1”到“std::vector<ArrayIndex>getNextRowColumn(std::vector<ArrayIndex>**)”,无法将“std::vector<ArrayIndex>(*)[2]”转换为“std::vector<ArrayIndex>**”
EN

Stack Overflow用户
提问于 2018-06-18 02:00:47
回答 1查看 135关注 0票数 -2

我有过

代码语言:javascript
复制
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>**)’

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-18 02:12:21

我猜你想把C数组作为参数传递给一个函数,然后你需要类似这样的东西

代码语言:javascript
复制
void fn()
{
    vector<ArrayIndex> IntermediateIndex[2];
    getNextRowColumn(IntermediateIndex);
}

void getNextRowColumn(vector<ArrayIndex>*  IntermediateIndex)
{
}

但是,由于问题是标记为C++的,例如,您最好坚持使用C++语义

代码语言:javascript
复制
void fn()
{
    array<vector<ArrayIndex>, 2> IntermediateIndex;
    getNextRowColumn(IntermediateIndex);
}

void getNextRowColumn(array<vector<ArrayIndex>, 2>&  IntermediateIndex)
{
}

或者使用vector<vector<…>>,取决于你要用它做什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50899193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档