Hi, I'm fairly new to C++. I'm trying to make a priority queue with a binary search tree. My BST class is
Code:template <class T>
class BST
{
private:
class Node
{
public:
T Value;
Node* Left;
Node* Right;
Node(const T& value)
{
Value = value;
Left = NULL;
Right = NULL;
}
};
Node* Root;
public:
BST()
{
Root = NULL;
}
~BST()
{
}
void Add(const T& value)
{
Node* node = new Node(value);
...
}
My problem is here:Code:#include "BST.h"
template <class T, class K>
class PriorityQueue
{
private:
class PriorityNode
{
public:
T Value;
K Priority;
PriorityNode(T value, K priority)
{
Value = value;
Priority = priority;
}
inline bool operator<(const PriorityNode& node) const
{
...
}
inline bool operator==(const PriorityNode& node) const
{
...
}
};
BST<PriorityNode> Bst;
public:
void Add(T value, K priority)
{
PriorityNode* node = new PriorityNode(value, priority);
Bst.Add(*node);
...
}
};
PriorityNode* node = new PriorityNode(value, priority);
Bst.Add(*node);
When I try to add to the Bst, it expects type T instead of PriorityNode.