<分区>
我正在尝试对 struct
的 vector 进行排序,但它以错误结束。我试着按照C++的引用去做,但我不知道问题出在哪里。有人可以帮助我吗?
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
/*
*
*/
struct reg{
string name;
string addr;
};
int main(int argc, char** argv) {
vector <reg> a;
reg newReg = { "John", "Street1"};
a.push_back(newReg);
reg newReg2 = { "Mike", "Street2"};
a.push_back(newReg2);
std::sort (a.begin(), a.end());
return 0;
}