i want to populate a list l from a vector s , line 79 is giving an error;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
# include <iostream>
# include <algorithm>
# include <vector>
# include <list>
# include <string>
using namespace std;
struct studentinfo {
string name;
int grade;
};
class markinfo {
public:
vector<studentinfo> pass;
vector <studentinfo> fail;
};
markinfo passfail( const vector<studentinfo> & s)
{
markinfo m;
for(auto x:s)
if (x.grade >= 50)
{
m.pass.push_back(x);
}
else
{
m.fail.push_back(x);
}
return m;
}
bool name(const studentinfo & lhs, const studentinfo & rhs)
{
return lhs.name < rhs.name;
}
int main()
{
vector <studentinfo> s;
studentinfo sinfo;
sinfo.name = "gg";
sinfo.grade = 44;
studentinfo sinfo2;
sinfo2.name = "aa";
sinfo2.grade = 77;
s.push_back(sinfo);
s.push_back(sinfo2);
sort(s.begin(), s.end(), name);
markinfo m;
m = passfail(s);
cout << " test " << endl;
list <studentinfo> l;
l.insert((s.begin(), s.end()));
//ist <studentinfo> ll = ;
/*
for (auto x : m.pass)
{
cout << x.name << x.grade << endl;
}*/
for (auto x : s)
{
cout << x.name << x.grade << endl;
}
}
|
Last edited on
how come insert takes on 3 arguments
lst.insert( lst.end(), vec.begin(), vec.end() ) ;