키워드: std::string · 입력(>>, getline) · 출력(<<) · 기본/복사/직접 초기화 · empty() · size() · size_t · auto · 연결 + · 누적 += · 연산자 오버로딩 · EOF/공백 처리
std::string은 **클래스(구조)**이며, 데이터 멤버 + 멤버 함수를 가진다.>> 는 공백(스페이스/탭/개행) 기준으로 단어 하나를 읽고, getline 은 줄 전체(개행 포함 X) 를 읽는다.while (cin >> s) { ... } / while (getline(cin, line)) { ... } → 입력 성공 시 true.=).string.empty() → 비었는지(bool), string.size() → 길이(size_t).size_t는 플랫폼 의존적인 부호 없는 정수. 혼합 연산 시 부호 변환 주의.+, 누적 += 는 자주 쓰는 패턴.+, <<, >> 등이 문맥에 맞게 재정의되어 작동(문자열 연결/스트림 입출력). introduction to programming 2 9…operator>>std::string s;
while (std::cin >> s) {
// s: 공백으로 분리된 "단어" 하나
std::cout << s << "\\n";
}