#include <iostream>
#include <map>
#include <string>
#include <iterator>
using namespace std;

int main() {
	map<string, string> myMap;

	myMap.insert(make_pair("김철수", "010-123-5678"));
	myMap.insert(make_pair("홍길동", "010-123-5678"));

	myMap["최자영"] = "010-123-5680";
	// 모든 요소 출력
	for(auto &it : myMap) {
		cout << it.first << " :: " << it.second << endl;
	}
	if (myMap.find("김영희") myMap.end())
		cout << "단어 '김영희'는 발견되지 않았습니다." << endl;
	return 0;
}

<aside> ➡️ 김철수 :: 010-123-5678 최자영 :: 010-123-5680 홍길동 :: 010-123-5679 단어 '김영희'는 발견되지 않았습니다.

</aside>

Lab: 영어사전 - 맵을 이용해 영어 사전 구현

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
	string word;
	map<string, string> dic;
	dic["boy"] = "소년";
	dic["school"] = "학교";
	dic["office"] = "직장";
	dic["house"] = "집";
	dic["morning"] = "아침";
	dic["evening"] = "저녁";

	while(true) {
		cout << "단어를 입력하시오:";
		cin >> word;
		if(word == "quit") break;
		string meaning = dic[word];
		if(meaning != "")
			cout << word << "의 의미는" << meaning << endl;
	}
	return 0;
}

<aside> ➡️ 단어를 입력하시오: boy boy의 의미는 소년 단어를 입력하시오: house house의 의미는 집 단어를 입력하시오: quit

</aside>