[
next
] [
prev
] [
prev-tail
] [
tail
] [
up
]
1.1.9.1
function pointer
A real example of function pointer is set_new_handler. It accepts a function pointer and return the same function pointer, so delcaring such format is a little difficult.
void
failNew
(){
cerr
<<
"
Fail
␣
now
"
<<
endl
abort
();
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
extern
void
(
*
set_new_handler
(
void
(
*
)()
)
)
();
//
This
function
declaration
is
very
complex
.
set_new_handler
(
failNew
);
A better method is to use typedef method.
typedef
void
(
*
FunPtr
)();
FunPtr
(
*
set_new_handler
)
(
FunPtr
);
set_new_handler
(
failNew
);
[
next
] [
prev
] [
prev-tail
] [
front
] [
up
]