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.

Chapter 28: Standardizing on the Standard Template Library 369The code necessary to iterate through a list is different from that necessaryto traverse a vector (to name just two examples). However, the iteratorhides these details.The following STLListUserClass program uses an iterator to traverse an STLlist in a non-destructive way:// STLListUserClass - use a list to contain and sort a// user defined class#include #include #include #include #include using namespace std;// Student - some example user defined classclass Student{public:Student(char* pszName, int id){name = new string(pszName);ssID = id;}string* name;int ssID;};// the following function is required to support the// sort operationbool operator

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

Saved successfully!

Ooh no, something went wrong!