2017-10-06 81 views
1

阵列这是我想要创建一个功能可按哪里可以通过的 结构称为节点传递的节点的数组起作用并返回节点

阵列declearing功能

void shellSort(node* arr[]); 

node* arrayz; 
arrayz = new node[counterElements] 

如何我调用函数

shellSort(arrayz); 

//How I define the function 
void lists::shellSort(node* arrayz[]) 
{ 
//code here 
} 

错误说无效名单::希尔排序(节点**)不匹配任何类列表//我的类被称为列表

+1

声明'shellSort(node *)'和'shellSort(node * arrayz [])'的定义不同。你应该定义为'shellSort(node * arrayz)'。 –

+0

你应该考虑在数组中传递'number of items'。否则,你将不会知道'shellSort'函数中的长度。 – MKR

回答

1

您应该将数组中的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);