Skip to content
Quiz · Containers and Iterators · lesson 4 of 11

Quiz — operator[] on a map

What does the program print?

C++
#include <iostream>
#include <map>
#include <string>

int main() {
    std::map<std::string, int> m{{"a", 1}};
    int b = m["b"];
    std::cout << b << ' ' << m.size() << '\n';
}