[C++] 멤버 함수포인터 사용하기 출처 : http://teamblog.joinc.co.kr/yundream/95 여러분은 함수포인터를 사용해봤을 것이다. C에서 제공하는 qsort(3)와 같은 함수도 함수포인터를 사용한다. 다음은 qsort(3)을 이용해서 정렬하는 간단한 프로그램이다. #include #include #include int compare(const int *one, const int *two) { if (*one > *two) return -1; else return 1; } int a[3] = { 50, 10, 20 }; int main() { qsort(a, 3, sizeof(a[0]), compare); print("%d\n", a[0]); return 0; }qsort 함수는 인자로, 비교에 사용할 함수의 포인.. 더보기 이전 1 ··· 43 44 45 46 47 48 49 ··· 77 다음