C++调用设计地下系统隐式删除默认构造函数
发布时间:2022-03-02 22:44:57 425
相关标签: # golang
我真的不确定我为什么会犯这个错误。给出错误消息:
Line 132: Char 38: error: call to implicitly-deleted default constructor of 'UndergroundSystem'
UndergroundSystem* obj = new UndergroundSystem();
^
Line 2: Char 56: note: default constructor of 'UndergroundSystem' is implicitly deleted because field 'getthem' has a deleted default constructor
unordered_map, pair> getthem;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/unordered_map.h:141:7: note: explicitly defaulted function was implicitly deleted here
unordered_map() = default;
class UndergroundSystem {
unordered_map, pair> getthem;
unordered_map> idcenter;
public:
UndergroundSystem() {
}
void checkIn(int id, string stationName, int t) {
idcenter[id]={stationName, t};
}
void checkOut(int id, string stationName, int t) {
auto passenger=idcenter[id];
string fromt=passenger.first;
string whereto=stationName;
int start=passenger.second;
idcenter.erase(id);
getthem[{fromt, whereto}].first++;
getthem[{fromt, whereto}].second+=t-start;
}
double getAverageTime(string startStation, string endStation) {
auto array=getthem[{startStation,endStation}];
int size=array.first;
int sum=array.second;
return sum/size;
}
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报