일반 함수
1 2 3 4 5 6 7 8 9 | void main( void ) { typedef int (*FUN_POINT_PRINTF)( const char *, ...); FUN_POINT_PRINTF _printf = printf ; _printf( "%s world !!!\n" , "hello" ); } |
클래스 내에 맴버 함수
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class member_func { public : int func( const char * string) { return printf (string); } }; void main( void ) { typedef int (member_func::*FUN_POINT_PRINTF)( const char *); FUN_POINT_PRINTF _func = &member_func::func; member_func member_func_obj; (member_func_obj.*_func)( "hello world !!!\n" ); } |
함수 포인터를 클래스로 wapper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class wrapper_func { typedef int (*FUN_POINT_PRINTF)( const char *, ...); public : wrapper_func(FUN_POINT_PRINTF func_point_printf) : func_point_printf_(func_point_printf) {} int operator() ( const char * string) { return func_point_printf_(string); } private : FUN_POINT_PRINTF func_point_printf_; }; void main( void ) { wrapper_func wapper( printf ); wapper( "hello world !!!\n" ); } |
'programming' 카테고리의 다른 글
SQL 데이타 타입에 매칭 되는 C++ 변수 타입 (0) | 2012.02.01 |
---|---|
템플릿 특화(Template specialize)를 이용한 BOOST_STATIC_ASSERT (0) | 2010.12.08 |
인터넷 브라우져의 Navigate 수행으로 로컬 파일 실행시키기 (0) | 2009.10.05 |
TCP 소켓에서 KEEPALIVE 옵션 사용 (4) | 2009.04.13 |
Visual Studio 2005 (VC++) 원격 디버깅 하기 (0) | 2009.04.07 |