#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
}
我的目的是在堆中创建一个新的nodeT
。错误是:在结构体中使用'new'关键字在C++中
错误C2512:“NODET”:可用
该代码没有任何问题 - “coordT”有一个隐式生成的构造函数,它什么都不做。你真的从该代码中得到错误吗?它究竟说什么? –
错误C2512:'nodeT':没有适当的默认构造函数可用 – SegFault
您有不同的问题。你提供的代码编译得很好(你是否声明了任何构造函数?)你可以尝试粘贴它到ideone或任何其他类似的页面来验证这一点。 –