웹프로그래밍
1. 문자열 인덱싱 인덱싱(indexing)이란 무엇인가를 ‘가리킨다’는 의미이고, 슬라이싱(slicing)은 무엇인가를 ‘잘라낸다’라는 의미이다. 이것들을 생각하면서 다음의 예를 따라해 보도록 하자.>>> a = "Life is too short, You need Python" Life is too short, You need Python 0 1 2 3 0123456789012345678901234567890123 각 문자열의 문자마다 번호를 매겨 보았다. 즉 "Life is too short, You need Python"이라는 문자열에서 'L'은 첫 번째 자리를 뜻하는 숫자인 0을 바로 다음인 'i'는 1을 이런식으로 계속 번호를 붙인 것이다. 중간쯤에 있는 "short"의 s는 12라는 번호가 된..
함수객체나 함수포인터나 기능적으로는 거의 비슷하지만 함수객체가 더 뛰어난 이유중 중요한 한가지는 함수객체는 인라인이 가능하기 때문에 속도를 향상시킬 수 있다는 것 이다. 예를들어 정렬 알고리즘에 함수객체가 아닌 함수포인터를 사용하면 비교연산을 할 때마다 함수를 호출해야 하기 때문에 시간이 오래걸릴 것이다. 함수 객체는 클래스 안에 함수를 캡슐화해 놓은 것으로 함수 포인터에 대한 일반화라 할 수 있다. 함수 객체는 타입이므로 템플릿의 인수로 사용될 수 있지만 함수 포인터는 단순한 값일 뿐이므로 템플릿의 인수로는 사용할 수 없다. 연관컨테이너들은 내부적인 정렬 방식을 결정하기 위해 함수 객체를 요구하는데 여기에 함수 포인터를 쓸 수는 없다. #include #include #include using name..
dfb_some_function 에서 dfb_refresh_timelines를 스레드로 생성하는 예제. class dfb{ public: void dfb_some_function(); friend void *call_dfb_refrash_timelines(void *arg); void dfb_refresh_timelines(); private: pthread_t thread_refresh_ui; } void *call_dfb_refrash_timelines(void *arg){ static_cast(arg)->dfb_refresh_timelines();}void dfb::dfb_refresh_timelines(){ printf("Hello\n"); }void dfb::dfb_some_function(){..