I’d been trying to insert some key and values the following way, but I’m getting an error that error: no matching constructor for initialization of 'Edge'
. I’m using C++17:
This is my program:
#include <iostream>
#include <string>
#include <map>
struct Edge
{
int v1{};
int v2{};
Edge (int v1, int v2)
:v1{v1}, v2{v2}
{
}
};
int main()
{
std::map<std::string, Edge> mymap;
mymap["edge1"] = Edge(0,0);
mymap["edge2"] = Edge(1,1);
return 0;
}
I’m pretty sure my constructor is correct, but any help is highly appreciated.
1