#include <map>
#include <list>
#include <string>
using namespace std;
class course {
public:
string course_name;
int section;
int credits;
course(string s, int sec, int c){ course_name = s; section = sec; credits = c; }
course(string s){ course_name = s; }
bool operator == (course c){
if (course_name == c.course_name) return true;
else return false;
}
};
void print_db(map<int, list<course> *> &db);
int main(){
map<int, list<course> *> db;
db[1111] = new list < course > ;
course c1("MAT296", 8, 4), c2("CSE283", 1, 3), c3("MAT397", 6, 4), c4("CHE106", 5, 1);
db[1111]->push_front(c1);
db[1111]->push_front(c2);
db[2222] = new list<course>;
db[2222]->push_front(c3);
db[2222]->push_front(c4);
print_db(db);
getchar();
}
void print_db(map<int, list<course> *> &db) {
list<course>::iterator it2;
map<int, list<course> *>::iterator it1 = db.begin();
for (size_t i = 0; i < db.size(); i++) {
cout << it1->first << endl;
it2 = it1->second->begin();
for (size_t j = 0; j < it1->second->size(); j++){
cout << it2->course_name <<" "<< it2->section << " " << it2->credits << endl;
it2++;
}
it1++;
}
}
#include <list>
#include <string>
using namespace std;
class course {
public:
string course_name;
int section;
int credits;
course(string s, int sec, int c){ course_name = s; section = sec; credits = c; }
course(string s){ course_name = s; }
bool operator == (course c){
if (course_name == c.course_name) return true;
else return false;
}
};
void print_db(map<int, list<course> *> &db);
int main(){
map<int, list<course> *> db;
db[1111] = new list < course > ;
course c1("MAT296", 8, 4), c2("CSE283", 1, 3), c3("MAT397", 6, 4), c4("CHE106", 5, 1);
db[1111]->push_front(c1);
db[1111]->push_front(c2);
db[2222] = new list<course>;
db[2222]->push_front(c3);
db[2222]->push_front(c4);
print_db(db);
getchar();
}
void print_db(map<int, list<course> *> &db) {
list<course>::iterator it2;
map<int, list<course> *>::iterator it1 = db.begin();
for (size_t i = 0; i < db.size(); i++) {
cout << it1->first << endl;
it2 = it1->second->begin();
for (size_t j = 0; j < it1->second->size(); j++){
cout << it2->course_name <<" "<< it2->section << " " << it2->credits << endl;
it2++;
}
it1++;
}
}