I'm having an error when trying to use the strcmp function. Here's the jist of the code I'm working with:
Code:
class Seller
{
public:
Seller();
Seller( char [], char[], char [], double );
void print();
void setFirstName( char [] );
void setLastName( char [] );
void setID( char [] );
void setSalesTotal( double );
void increaseSalesTotal( double );
char * getFirstName();
char * getLastName();
char * getID();
double getSalesTotal();
private:
char firstName[20];
char lastName[30];
char sellerID[7];
double sales;
};
in main:
Seller sellerArray[30];
methods:
char* Seller::getID()
{
return sellerID;
}
void sortSellersByID(Seller sellerArray[], int size)
{
int i, j; // more variables then a structure variable.
Seller tmp; // well, this is more like a temporary variable in our structure... so that we could not have some weird compiler errors
for (i=0; i<size; i++)
{
for (j = 0; j < size; j++)
{
if (strcmp(sellerArray[i].getID, sellerArray[j].getID) < 0)
{
tmp = sellerArray[i];
sellerArray[i] = sellerArray[j];
sellerArray[j] = tmp;
}
}
}
}
I'm getting a
"[Error] cannot convert 'Seller::getID' from type 'char* (Seller:: )()' to type 'const char*'"
on this line of code:
"if (strcmp(sellerArray[i].getID, sellerArray[j].getID) < 0) "
How do i have this method able to compare these values in my seller array? Granted, there is more to the code and things actually in the seller array at this point. Is there something I'm not seeing??