我有一个关于循环模板引用的问题。我想使用类节点和类边缘制作一棵树,如下所示;
template <typename EdgeT>
class node
{
public:
std::vector<EdgeT> edge_out;
std::vector<EdgeT> edge_in;
};
template <typename NodeT>
class edge
{
public:
NodeT* src;
NodeT* dst;
int weight;
};
template <typename NodeT, typename EdgeT>
class graph
{
public:
std::vector<NodeT> nodes;
};
我发现我无法声明图形类 ex:
graph< node, edge > g; // <--- this cannot be solved
graph< node< edge <node.....>, edge< node< edge>> > //it makes infinity declaration..
如何重新定义类的结构?