11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

372Part V: Optional Featuresusing namespace std;// SC - Student comparison function; designed to determine// the sorting order of the studentsstruct SC{bool operator()(const int id1, const int id2) const{return id1 < id2;}};// the map actually contains a Pair; the left element// being the key while the right element is the data (in// this case Student)class Student;typedef Student* SP;typedef pair Pair;typedef map Map;typedef map::iterator MapIterator;// collection of StudentsMap students;// Student - define the important properties of a student// including the key use when looking him/her up// from the student rolls(student id)class Student{public:Student(char* pszName, int id): studentIDKey(id), name(pszName) {}// getKey - the key is used as an index into the mapconst int getKey() { return studentIDKey; }// display - create a meaningful output// for a Student objectstring display(){ostringstream out;out

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!