我正在编写一个程序,该程序将读取具有社会安全号码的名称列表(当然不是真实的名称),并根据命令行参数根据姓氏或ssn对列表进行排序。为了简单起见,我已经重载了<运算符和重载了输入和输出运算符。一切都可以正常编译,直到我在main末尾添加sort函数和输出为止。我很沮丧 有任何想法吗?任何其他提示也将不胜感激。
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <fstream>
using namespace std;
enum sortVar { NAME, SOCSEC };
class record {
public:
friend bool operator<(record& rhs, record& name);
friend ostream& operator<<(ostream& out, record& toWrite);
friend istream& operator>>(istream& in, record& toRead);
bool t_sort;
private:
string firstName, lastName, ssn;
};
bool operator<(record& rhs, record& next)
{
if (rhs.t_sort = false) {
if (rhs.lastName == next.lastName)
return rhs.firstName < next.firstName;
else
return rhs.lastName < next.lastName;
}
else if (rhs.t_sort = …Run Code Online (Sandbox Code Playgroud)