I want to get map's keys, save in a vector, so i write the following code:
#include <vector>
#include <iostream>
#include <map>
using namespace std;
int main() {
map<int, int> m = {{1,2}, {4,5}, {6,7}};
vector<int> a(m.begin()->first, m.end()->first);
for (auto i : a) {
cout << i << endl; // output 3 here
}
}
this code print 3 only, which confuse me. I never input 3 into map, where is 3 comes out?