mit dem folgende Code sollte es funktionieren :
#include <iostream.h>
#include <string.h>
#include <map>
class Name {
public:
char name[20];
Name() {
}
Name(char *name){
strcpy(this->name, name);
}
};
struct compareNames {
bool operator()(Name n1, Name n2) const {
return strcmp(n1.name, n2.name) < 0;
}
};
int main(){
std::map<Name, Name, compareNames> m;
std::map<Name, Name, compareNames>::iterator i;
std:: pair<Name,Name> p;
p.first = *(new Name("Mueller"));
p.second = *(new Name("Josef"));
m.insert(p);
p.first = *(new Name("Faerber"));
p.second = *(new Name("Franz"));
m.insert(p);
p.first = *(new Name("Gerber"));
p.second = *(new Name("Hubert"));
m.insert(p);
for(i = m.begin(); i != m.end(); i++)
cout << i->second.name << endl;
return 0;
}