Hello! I have a very simple class, called Node.
Node.h
#ifndef NODE_H
#define NODE_H
#include <QSet>
class Node
{
public:
Node();
Node(const uchar &c);
uchar val;
QSet<Node> childNodes;
bool addChild(const Node& node);
inline bool operator==(const Node &n1, const Node &n2)
{
return n1.val == n2.val;
}
inline uint qHash(const Node &node)
{
return qHash(node.val);
}
};
#endif // NODE_H
#ifndef NODE_H
#define NODE_H
#include <QSet>
class Node
{
public:
Node();
Node(const uchar &c);
uchar val;
QSet<Node> childNodes;
bool addChild(const Node& node);
inline bool operator==(const Node &n1, const Node &n2)
{
return n1.val == n2.val;
}
inline uint qHash(const Node &node)
{
return qHash(node.val);
}
};
#endif // NODE_H
To copy to clipboard, switch view to plain text mode
Node.cpp
#include "Node.h"
Node::Node()
{
val = -1;
}
Node::Node(const uchar &c)
{
val = c;
}
bool Node::addChild(const Node &node)
{
if(childNodes.contains(node))
return false;
childNodes.insert(node);
return true;
}
#include "Node.h"
Node::Node()
{
val = -1;
}
Node::Node(const uchar &c)
{
val = c;
}
bool Node::addChild(const Node &node)
{
if(childNodes.contains(node))
return false;
childNodes.insert(node);
return true;
}
To copy to clipboard, switch view to plain text mode
I get the following error messages:
- 'bool Node::operator==(const Node&, const Node&)' must take exactly one argument
- no matching function for call to 'qHash(const Node&)'
- no match for 'operator==' in key0==((QHashNode<Node, QHashDummyValue*)this)->QHashNode<Node,QHashDummyValue>::key'
What can be the problem?
Thanks in advance!
Bookmarks