pointer to function
Initialized & Implicit Conversion
- A [pointer to function] can be initialized with an address of a [non-member function] or a [static member function].
- [function-to-pointer implicit conversion]
1 |
void (int); |
[this] invokes the [pointed-to function]
- Unlike [functions] or [references to functions], [pointers to functions] are [objects] and thus can be stored in [arrays, copied, assigned], etc.
- A [pointer to function] can be used as the [left-hand operand] of the function call operator, [this] invokes the [pointed-to function]:
1 |
int (int n) |
Dereferencing
Dereferencing a function pointer yields the [lvalue identifying the pointed-to function]:
1 |
int (); |
Initialized from an overload
A pointer to function may be initialized from an overload set which may include functions, function template specializations, and function templates, if only one overload matches the type of the pointer (see address of an overloaded function for more detail):
1 |
template<typename T> T (T n) { return n; } |
Equality comparison operators are defined for pointers to functions (they compare equal if pointing to the same function).
to be continued…
近期评论