Hi! I was using #include <list> and sort it with sort(). The problem is that i cant sort the member variables outside the class because they were set to protected, I can only call the access functions but then this wouldn't change the original order of the variables, when I tried writing the bool operator<(Account& s1, Account& s2) inside the class the compiler complains that it must take exactly one argument. I want the member variable to stay protected and then sort it from inside the class. I wish you could help me with this.
Not sure what you're trying to point out with the two copies of your class.
Several problems:
1) Your listAcc is a list<AccPtr> i.e. a list of pointers, so sort will be expecting a < operator that accepts a const AccPtr. If you want to sort a list of pointers based on name ordering, you will have to dereference the pointers.
2) The < operator should be public. You have it as protected. list<>.sort can't call a protected member.
3) As Pindrought pointed out, the < operator should take ONE argument.
This has nothing to do with the fact that the variables are protected. As long as the < operator is a member of the class it will see the protected members without issue.
BTW, you're only sorting on last name. No guarantee that if two last names are the same, the entries will also be in order by first name.