I am trying to sort the Structure by author and title
when i try to sort it by author it will only let me sort
the author and not the title with it.
so, when i sort by author the title is wrong.
heres what i have:
Code:
struct Library {
string Title;
string Author;
};
const int ARRAY_SIZE = 1000;
Library books [ ARRAY_SIZE ];
Code:
void SortByAuthor( int count )
{
string temp;
for ( int index = 1; index < count; index++ )
{
for( int i = 0; i < count; i++ )
if(books[i].Author > books[index].Author)
{
temp = books[i].Author;
books[i].Author = books[index].Author;
books[index].Author = temp;
}
}
now I would imagine
I would want to do this:
Code:
if(books[i].Author > books[index].Author)
{
temp = books[i];
books[i] = books[index];
books[index] = temp;
}
to copy the whole struct but, i get errors.
Code:
1>error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Library' (or there is no acceptable conversion)
whats wrong?
thanks in advance.