Need help in Bubble_Sorting in Array

Hello I need help to complete bubble sort in array for customers telephone names.
This is what I have done, I need help to cout it Before_Name and After_Name when I runs the code
This is my code here:



void Bubblesort(string Customer *x[],int top) //This Bubblesort function
{
string str1,str2;
for(int i=0;i<top;i++)
{
str1=x[i]->getname();
for(int j=0;j<i-1;j++)
{ str2=x[j]->getname();
if(str1.compare(str2)==-1)
{
Customer *t;
t=x[i]; x[i]=x[j];x[j]=t;
}
}
}
}
ico
Use code tags, this is especially hard to read from my phone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//This Bubblesort function
void Bubblesort(string Customer *x[],int top)
{
	string str1,str2;
	for(int i=0; i < top; i++)
	{
		str1 = x[i]->getname();
		for(int j = 0; j < i-1; j++)
		{
			str2 = x[j]->getname();
			if(str1.compare(str2) == -1)
			{
				Customer *t;
				t = x[i]; 
				x[i] = x[j];
				x[j] = t;
			}
		}
	}
}


Can you show us the getname() ?
string Customer *x[],

This makes no sense to me. I imagine x is supposed to be an array of Customers, so why is the "string" there? Also, *x[] is a pointer to an array, not a pointer/array. Just Customer *x should be fine, I think.
Topic archived. No new replies allowed.