在c ++中使用带有struct的'new'关键字

Seg*_*ult 1 c++ compiler-errors new-operator dynamic-allocation

#include "PQueue.h"

struct arcT;

struct coordT {
    double x, y;
};

struct nodeT {
    string name;
    coordT* coordinates;
    PQueue<arcT *> outgoing_arcs;
};

struct arcT {
    nodeT* start, end;
    int weight;
};

int main(){
    nodeT* node = new nodeT; //gives error, there is no constructor
}
Run Code Online (Sandbox Code Playgroud)

我的目的是nodeT在堆中创建一个新的.错误是:

错误C2512:'nodeT':没有合适的默认构造函数可用

Dar*_*con 5

PQueue<arcT *>没有合适的默认构造函数,因此nodeT编译器无法生成默认构造函数.为适当的构造创建适当的默认构造函数PQueue<arcT *>或添加用户定义的默认构造nodeT函数outgoing_arcs.