I cannot solve the error - main.cpp:31:34: error: ‘sortBook’ was not declared in this scope in the line sortBook(arr,arr+n,comparator);
I apologize for asking a question that should have a simple solution, but it's driving me nuts. I've checked for all the common errors.
#include<iostream>
using namespace std;
class BOOK{
private:
char bookname[20];
float bookprice;
public:
void getBookDetails()
{
cout<<"Enter the Book Name:";
cin>>bookname;
cout<<"Enter the Book Price:";
cin>>bookprice;
}
void displayDetails()
{
cout<<"Book Name:"<<bookname<<endl;
cout<<"Book Price:"<<bookprice<<endl;
}
};
bool comparator(string a,string b)
{
return a<b;
}
int main()
{
int n=5;
string arr[]={"sandwich","apple","banana","zombie","pear"};
sortBook(arr,arr+n,comparator);
for(int i=0;i<n;i++)
{
cout<<arr[i]<<" ";
}
}