C++ STL list 删除一个元素(remove) 报错!!
#include <iostream>
#include <cstdlib>
#include <string>
#include <bitset>
#include <vector>
#include <iterator>
#include <list>
#include <unistd.h>
#include <istream>
#include <iomanip>
using namespace std;
struct student
{
char *name;
char *address;
char *tel;
float score;
};
//我定义了一个结构体,然后定义了结构体list,向结构体list扔了4个元素,然后想remove掉其中的一
//个,结果在remove的时候报错了
int main(int argc,char *argv[])
{
student stu;
list<student> stulist;
stu.name="chenyigeng";
stu.address="hebei";
stu.tel="13811114116";
stu.score=1123.423;
stulist.push_back(stu);
stu.name="lijie";
stu.address="henan";
stu.tel="13411323116";
stu.score=123.423;
stulist.push_back(stu);
stu.name="xuhontao";
stu.address="shandong";
stu.tel="122311323116";
stu.score=1123.423;
stulist.push_back(stu);
stu.name="jianian";
stu.address="langfang";
stu.tel="13423323116";
stu.score=12334.423;
stulist.push_back(stu);
student s1={"lijie","henan","13411323116",123.423};
const student &ss=s1;
stulist.remove(ss); //这里编译不通过
system("pause");
return 0;
}