Hi,
main.cpp
vector<Employee>e;
e.push_back(Employee("Hawaii",100));
cout<<endl;
e.push_back(Employee("Scotland",20));
cout<<endl;
e.push_back(Person("Saga",30));
cout<<endl;
Employee e1; //created an object
sort(e.begin(),e.end());
e1.show(e);
Employee.h
bool operator<(const Employee& e1,const Employee& e2);
Employee.cpp
bool operator<(const Employee& e1,const Employee& e2)
{
return e1.getName() < e2.getName();
}
With this code it is just sorting only the first 2 objects and displaying the output as Hawaii 100,Saga 30,Scotland 20.
Please let me know what is the mistake in my code.