[英]Passing array of nodes to function and returning an array of nodes
這是我想創建一個函數的地方,我可以在其中傳遞一個名為 node 的結構數組
聲明函數
void shellSort(node* arr[]);
node* arrayz;
arrayz = new node[counterElements]
我如何調用函數
shellSort(arrayz);
//How I define the function
void lists::shellSort(node* arrayz[])
{
//code here
}
錯誤說 void lists::shellSort(node**) 與類列表中的任何內容都不匹配 //我的類稱為列表
您應該將數組中number of items
傳遞給“shellSort”函數。 基於此,函數的聲明應該是:
void lists::shellSort(node* arrayz, int nItems)
{
//code here
}
//You should call this function as
node* arrayz;
arrayz = new node[counterElements]
shellSort(arrayz, counterElements);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.