在CPP中互相访问的两个结构

Two structs that access eachother in cpp

本文关键字:两个 结构 CPP 访问      更新时间:2023-10-16

我有两个相互访问的结构。我向前宣布它们,但仍然存在编译器错误。

'node'在此范围中没有声明,而'node'未命名类型。

struct Node;
struct Edge;
struct Node
{
    unsigned intersectionID;
    bool visited;
    std::vector <Edge*> leavingedges;
};
struct Edge
{
    unsigned streetsegmentID;
    double weight;
    Node* endingnode;
};

您忘记了#include <vector>。当我添加时,您的代码会罚款。