I am trying to print the elements in pair, but it's throwing an error: "no matching function call"
Code:
#include <utility>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
pair<int, string> pairVec;
pairVec =make_pair(1, "One");
pairVec=make_pair(2, "Two");
pairVec=make_pair(3, "Three");
for(auto iter:pairVec){
std::cout << "First: " << iter.first << ", Second: "
<< iter.second <<std::endl;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire