0

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.

Edited by Dani: Formatting fixed

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Fbody
0

If you tell us what you expect the program to do and how what it's actually doing differs from the expected, we may be able to help you.

Until you establish your intent though, we can not help you because we don't know what behavior is considered correct and therefore do not know what behavior is considered incorrect.

Edited by Fbody: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.