The 11th plague of Egypt
14th September 2011, 16:54
I don't remember very well how to overload operators in a template, so I humbly hope somebody can help me with this.
I'd like to do something like this
Contact contact("Name", "Surname");
QMap<QString, Contact> map;
map.insert("first", contact);
qDebug() << map;
and have an output like this
first: Name Surname
This is a just a basic example to help me understand templates, I know there are simpler ways, like a for loop.
BTW is it possible to have a different overloading of << for QMap<QString, Contact> and QMap<Contact, QString> ?
I'd like to do something like this
Contact contact("Name", "Surname");
QMap<QString, Contact> map;
map.insert("first", contact);
qDebug() << map;
and have an output like this
first: Name Surname
This is a just a basic example to help me understand templates, I know there are simpler ways, like a for loop.
BTW is it possible to have a different overloading of << for QMap<QString, Contact> and QMap<Contact, QString> ?