Seite 1 von 1

Sonderzeichen ^ in qt4 doku

Verfasst: 20. Oktober 2010 09:45
von sowas
hallo,
in der qt4-Referenz zur QHash Klasse wird folgendes Beispiel aufgeführt:
----------
#ifndef EMPLOYEE_H
#define EMPLOYEE_H

class Employee
{
public:
Employee() {}
Employee(const QString &name, const QDate &dateOfBirth);
...

private:
QString myName;
QDate myDateOfBirth;
};

inline bool operator==(const Employee &e1, const Employee &e2)
{
return e1.name() == e2.name()
&& e1.dateOfBirth() == e2.dateOfBirth();
}

inline uint qHash(const Employee &key)
{
return qHash(key.name()) ^ key.dateOfBirth().day();
}

#endif // EMPLOYEE_H
----------
in der vorletzten Zeile erscheint das ^ Zeichen.
Was bewirkt es?
danke

Verfasst: 20. Oktober 2010 10:03
von Christian81

Verfasst: 20. Oktober 2010 10:06
von franzf
Einfach den Text rund um das Example auch lesen...
In the example above, we've relied on Qt's global qHash(const QString &) to give us a hash value for the employee's name, and XOR'ed this with the day they were born to help produce unique hashes for people with the same name.
Das "^" ist ein binär-Operator, namentlich "XOR". Google dich schlau, was "XOR" bedeutet :P

Sonderzeichen ^ in qt4 doku

Verfasst: 20. Oktober 2010 10:13
von sowas
danke,
ich habe den Text in der Doku auch entdeckt, aber ich glaube es ist einfacher zu fragen als die Doku aufmerksam zu lesen.

Verfasst: 20. Oktober 2010 17:07
von Herzogswalder
Fang lieber an die Doku aufmerksamer zu lesen!!!