
C++11부터 표준 라이브러리를 정규식을 편리하게 사용할 수 있다. 정규식이 복잡한 듯 보여도 알아두면 이만큼 요긴한 것이 없다. #include #include #include #include int main() { std::string sample_str = "In the beginning God created the heavens and the earth." "Now the earth was formless and empty, darkness was over the surface of the deep, " "and the Spirit of God was hovering over the waters."; std::regex test_search("GOD", std::regex_constants::EC..

Java나 C++과 같은 OOP(객체 지향 프로그래밍, Object Oriented Programming) 프로그래밍 언어를 다루다 보면 교과서에서 배웠던 다형성(Polymorphism)이 다시금 머리에 떠오른다. 동질이상(同質異像)이라 하여 화학적으로는 동일한 물질이지만 다른 구조를 갖는 것을 의미한다. 피부에 와닿는 예로 다이아몬드와 흑연이 그렇고 얼음, 물, 수증기가 비슷하다고 할 수 있다. OOP 프로그래밍에서는 Overloading(오버로딩)과 Overriding(오버라이딩)이 그 대표적인 예이다. ■ 오버로딩(Overloading) voidchildAdd( XMLNode *nd ); XMLNode* childAdd( const string &name = "" ); intchildIns( int..

프로그램 빌드 과정에서 가끔 한 번씩 만나면서도 자꾸 까먹는 실수로 인한 컴파일 에러 메시지이다. 직역을 하자면 비상수형 lvalue 참조를 할 수 없다는 것이다. 일단, lvalue는 "A=B"라는 문장이 있다면 대입연산자(=) 좌측에 있는 것을 말하고, 우측에 있는 것을 rvalue라고 한다. void dlgPou::SetPouNames(vector &pou_names) { PouNames.clear(); for (int ip = pou_names.size() - 1; ip >= 0 ; ip ++) { string str = ""; std::transform(pou_names[ip].begin(), pou_names[ip].end(), str.begin(), ::toupper); PouNames.pu..

C언어와 같은 전통적인 프로그래밍 언어에서는 함수에서 값을 리턴한다고 생각하면 정수나 구조체의 포인터와 같은 단일값을 생각하지만 파이썬이나 자바스크립트와 같은 요즘 많이 쓰는 언어에서는 서로 다른 타입의 값 두 개 뿐만 아니라 리스트를 넘길 수도 있다. C++에서는 리스트나 사전 타입이 아니라 단순히 두 개의 요소로 이루어진 객체를 위해서 std::pair라는 템플릿을 제공한다. std::pair parse_row(xml::parser *parser, xlnt::detail::number_serialiser &converter, std::vector &parsed_cells) { std::pair props; for (auto &attr : parser->attribute_map()) { if (stri..