![](/img/trans.png)
[英]How to convert void* to std::vector<std::vector<std::string> >*?
[英]cannot convert ‘std::vector<ArrayIndex> (*)[2]’ to ‘std::vector<ArrayIndex>**’ for argument ‘1’ to ‘void getNextRowColumn(std::vector<ArrayIndex>**)’
我有
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>**)'
我猜您想將 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<…>>
,取決於你打算用它做什么
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.