C++2 [c++] C++ Core Guidelines [[[내용 가운데 수정이 필요한 부분을 발견하시면 댓글로 알려주세요]]] C++ Core Guidelines In: 소개 P: 철학 I: 인터페이스 I.1: 명시적인 인터페이스를 만드세요. 이유 인터페이스에 명시되지 않은 가정은 간과하기 쉽고, 검증이 어렵습니다. 나쁜 예제 글로벌 변수를 통한 함수 제어는 암시적이고 혼란을 일을킬 수 있습니다. 예를 들면: int round(double d) { return (round_up) ? ceil(d) : d; // 보이지 않는 의존을 사용하지 마십시오. } round(7.2) 함수를 호출했을 때 결과 값이 다를 수 있어 함수 호출자에게는 의미가 분명하지 않을 수 있다. [^^: round_up 변수를 말하는 것이 아닐까?] 예외 가끔 환경 변수(예, 일반적인 .. 2019. 11. 6. [c++] std::map::operator[] mapped_type& operator[] (const key_type& k); http://www.cplusplus.com/reference/map/map/operator[]/ map::operator[] - C++ Reference mymap['a'] is an element mymap['b'] is another element mymap['c'] is another element mymap['d'] is mymap now contains 4 elements. www.cplusplus.com void function() const { std::map m; std::vector nums = {1, 2, 3, 4}; for (auto num : nums) { m[num].push_back(num); } .. 2019. 9. 17. 이전 1 다음