Good day! Himself toiled with a similar problem. In order to use iterators, for its class, as well as to use it in various typable structures like List <>, you need to define for your class some of the following constructs: default constructor, shocking constructor, comparison operator =, and also the function of obtaining white from your class. Exactly which ones are necessary - it is difficult to say for each of the typed classes this set is its own, but they are needed, if you have questions about what it is, I can dig and send you an example of my class working with such types. Here is my example, which I, at one time, took from the Qt documentation, partially added and used as the basis in subsequent classes:
Message.h
#ifndef MESSAGE_H #define MESSAGE_H #include <QHash> #include <QString> #include <QStringList> class Message { public: Message(); Message(const Message &other); ~Message(); Message(const QString &body, const QStringList &headers); QString body() const; QStringList headers() const; friend bool operator==(const Message& left, const Message& right); friend uint qHash(const Message& message); private: QString m_body; QStringList m_headers; }; #endif // MESSAGE_H
Message.cpp
#include "message.h" Message::Message() { } Message::Message(const Message &other) { m_body = other.body(); m_headers = other.headers(); } Message::~Message() { } Message::Message(const QString &body, const QStringList &headers) { m_body = body; m_headers = headers; } QString Message::body() const { return m_body; } QStringList Message::headers() const { return m_headers; } bool operator==(const Message& left, const Message& right) { return !left.body().compare(right.body()); } uint qHash(const Message& message) { return ::qHash(message.body()); }