[英]error: no matching function for call to 'Node::Node()' - second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
I've defined a structure like this:我定义了这样的结构:
struct Node
{
int32_t a;
int32_t b;
double c;
double d;
Node (int32_t a, int32_t b, double c)
{
this->a = a;
this->b = b;
this->c = c;
this->d = 0.0;
}
};
I'm implementing a map of map like this:我正在像这样实现 map 的 map:
unordered_map<UInt32,unordered_map<int32_t,Node>> data;
Upon using the below code.使用以下代码后。 I'm receiving error error: no matching function for call to 'Node::Node()' second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
我收到错误error: no matching function for call to 'Node::Node()' second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
data[instId][id].d += (value);
Please help out why I'm receiving error.请帮助我为什么收到错误。 I've also tried using auto& tree = data[instId]; tree[id].d += (value);
我也试过使用auto& tree = data[instId]; tree[id].d += (value);
auto& tree = data[instId]; tree[id].d += (value);
(PS: Pseudo code is mentioned) (PS:提到了伪代码)
It is because that unordered_map<int32_t,Node>
tries to call the constructor Node() with no argument, and because you defined the constructor with three argument, Node() is deleted.这是因为unordered_map<int32_t,Node>
试图调用不带参数的构造函数 Node(),并且因为您定义了具有三个参数的构造函数,所以 Node() 被删除。 Consider adding Node()=default;
考虑添加Node()=default;
inside the class definition.在 class 定义中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.