# Include <set> <br/> # include <string> <br/> # include <iostream> <br/> using namespace STD; </P> <p> class cemployee {<br/> Public: <br/> cemployee (); <br/> ~ Cemployee (); <br/> const string getname () const; <br/> void setname (const string name); <br/> const string gettitle () const; <br/> void settitle (String title); <br/> int GETID () const; <br/> void setid (int id); <br/> PRIVATE: <br/> int m_id; <br/> string m_username; <br/> string m_title; </P> <p >}; <br/> cemployee: cemployee () <br/>{</P> <p >}< br/> cemployee ::~ Cemployee () <br/>{< br/>}< br/> const string cemployee: getname () const <br/>{< br/> return m_username; <br/>}< br/> void cemployee: setname (const string username) <br/>{< br/> m_username = username; <br/>}</P> <p> const string cemployee: gettitle () const <br/>{< br/> return m_title; <br/>}</P> <p> void cemployee: settitle (String title) <br/>{< br/> m_title = title; <br/>}< br/> int cemployee: GETID () con St <br/>{< br/> return m_id; <br/>}< br/> void cemployee: setid (int id) <br/>{< br/> m_id = ID; <br/>}< br/> class sortbyid <br/>{< br/> public: <br/> bool operator () (cemployee const & _ A, cemployee const & _ B) const <br/>{< br/> If (_. GETID () <_ B. GETID () return true; <br/> If (_. GETID () = _ B. GETID () return _. getname (). compare (_ B. getname () <0; <br/> return false; <br/>}< br/>}; </P> <p> int Ma In () <br/>{< br/> set <cemployee, sortbyid> empidset; // se is an employee's set, <br/> set <cemployee, sortbyid> :: iterator ITER; <br/> cemployee employeeinfo; <br/> employeeinfo. setname ("employee_one"); <br/> employeeinfo. settitle ("employee"); <br/> employeeinfo. setid (1); <br/> empidset. insert (employeeinfo); <br/> cemployee employeeinfo2; <br/> employeeinfo2.setname ("employee_two"); <br/> employeeinfo2.settitle ("CFO"); <br/> employeeinfo2.setid (5); <br/> empidset. insert (employeeinfo2); </P> <p> cemployee employeeinfo3; <br/> employeeinfo3.setname ("employee_three"); <br/> employeeinfo3.settitle ("manager "); <br/> employeeinfo3.setid (3); <br/> empidset. insert (employeeinfo3); </P> <p> for (iter = empidset. begin (); iter! = Empidset. end (); ITER ++) <br/>{< br/> cout <ITER-> GETID () <"" <ITER-> getname () <"" <ITER-> gettitle () <Endl; <br/>}< br/> return 0; <br/>}< br/>