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';
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way