← Quiz: STL Containers: all 9 questions
Quiz: STL Containers · Question 4 of 9
What does this print? (code)
What does this print?
#include <iostream>
#include <map>
using namespace std;
int main() {
map<string, int> m;
int x = m["missing"];
cout << x << " " << m.size();
return 0;
}
- A.Error
- B.0 1
- C.0 0
- D.-1 0
Answer & explanation
Correct answer: 0 1
m["missing"] inserts the key with value 0, so the size becomes 1.
Can you get the rest right without peeking?
Take the timed Quiz: STL Containers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →