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':没有合适的默认构造函数可用
PQueue<arcT *>没有合适的默认构造函数,因此nodeT编译器无法生成默认构造函数.为适当的构造创建适当的默认构造函数PQueue<arcT *>或添加用户定义的默认构造nodeT函数outgoing_arcs.
| 归档时间: |
|
| 查看次数: |
2877 次 |
| 最近记录: |