Hello!
Something I blunted at the end of the day ... I can't implement a data set (of my class) using **std:set**.
Here is my data type, used for the data type in the container:
class employee { private: int id; string name; string adress; public: employee(int id2, string name2, string adress2):id(id2), name(name2), adress(adress2) {} employee(){id = 0; name=adress="";} employee(int id2):id(id2){name=adress=""; id = id2;} int getID(){return id;}; string getName(){return name;}; };
Nothing remarkable, right? I also overloaded several operations that need to be reloaded in order for some container methods like std :: set :: find () to work :
// Этот нужен для разнообразия... ostream &operator<<(ostream &s,employee &emp) { s<<emp.getName()<<endl; return s; } bool operator ==(employee a, employee b) { return a.getID()==b.getID(); } bool operator <(employee a, employee b) { return a.getID()<b.getID(); }
Next, I try to work with the container itself through iterators std :: set <class T> :: iterator :
set<employee> emp; emp.insert(employee(123)); emp.insert(employee(125)); emp.insert(employee(124)); set<employee>::iterator itr = emp.find(employee(125)); cout<<*itr->getID()<<endl; // не работает cout<<*itr<<endl; // тоже не работает...
What's wrong, guys? Tell me please...