I have made a small map that I call BMW
. It contains the keys Usage
and Diesel
, as shown below.
#include <iostream>
#include <bits/stdc++.h>
#include <map>
#include <vector>
using namespace std;
int main()
{
// initialize container
std::map<string, std::tuple<string, string>> BMW;
// insert elements
BMW.insert({"Usage", {"1", "2"}});
BMW.insert({"Disel", {"2", "3"}});
std::cout << "Usage => " << BMW.find('Usage')->second << '\n';
return 0;
}
What I want to do is to find the key Usage
in the map and then print out the strings containing the values for Usage
(1, 2). The code I tried with does not work and I am not able to find a good answer why here on Stackoverflow. Here is the error I get:
error: no matching function for call to 'std::map<std::__cxx11::basic_string<char>, std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::find(int)'|
It would be great if I could be able to get only one of the strings, like the first one, if I want to do that.
(the strings will later be converted to int when this is appropriate, but because of technical reasons I want to read them as strings for now)