#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或任何其他類似的頁面來驗證這一點。 –