Hi all i need some help in my merge sorting
class Database
{
protected:
struct data
{
string pName;
string pCat;
int pBarcode;
double pPrice;
string pMan;
int pStock;
int pSold;
data *next;
};//struture of product
}
void Database::topX(int number,data output[]){
data *cur=_head;
data* *sorted=new data*[_n];// new datatype:data array of _n size, pointer pointing to pointer sorted//
for(int i=0;i<_n;i++){
sorted[i]=cur;
cur= cur->next;
}//link list
mergeSort(*sorted,0,_n);
}
void Database::mergeSort(data sorted[],int low,int high){//divide step
//base case- when low < high: do nothing
if(low>high){
int mid=(high+low)/2;//divide array to 2
mergeSort(sorted,low,mid);
mergeSort(sorted,mid+1,high);
merge(sorted,low,mid,high);
}
}
void Database::merge(data sorted[],int low,int mid,int high){//conquer step
int n = high-low+1;
data* *b = new data*[_n];
int left=low, right=mid+1, bIdx=0;
while (left<=mid && right<=high) {
if (sorted[left].pSold <= sorted[right].pSold)
b[bIdx++] = sorted[left++];
else
b[bIdx++] = sorted[right++];
}
}
i guess i have mixed up my pointer.. please someone advise what is wrong with my code
error C2440: '=' : cannot convert from 'Database::data' to 'Database::data *'
error C2440: '=' : cannot convert from 'Database::data' to 'Database::data *'