반응형 C++ STL2 STL 문장 내 단어 검색 STL 문장 내 단어 검색문장을 입력하고 단어를 검색할 수 있는 멤버 함수를 가진 contents_t 클래스를 정의한다. STL을 이용하여 find 멤버함수로 문장 내 단어를 검색 할 수 있다. 소스코드 #include "stdafx.h" #include #include class contents_t { private: std::string contents; public: contents_t(std::string c) : contents(c) { } bool find(const std::string &x) const { if( contents.find( x ) == std::string::npos ) return false; // 같다면 ? return true; } }; int main(int argc.. 2010. 8. 9. STL C++ Standard Library 튜토리얼/레퍼런스 요약(3장~5장) STL C++ Standard Library 튜토리얼/레퍼런스 ▣ 3장 일반적인 개념 1. namespace std - 사용법 1. 식별자에 대해서 명시적으로 namespace의 이름을 적어주는 방법 예) std::cout 2010. 4. 23. 이전 1 다음 반응형