Pointer syntax: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(function pointer) |
(add category) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
<source lang="C++"> |
<source lang="C++"> |
||
return_type (* |
return_type (*function_name)(args...) |
||
</source> |
</source> |
||
Line 14: | Line 14: | ||
<source lang="C++"> |
<source lang="C++"> |
||
member_type type::* |
member_type type::*member_name |
||
</source> |
</source> |
||
Line 21: | Line 21: | ||
<source lang="C++"> |
<source lang="C++"> |
||
type obj; |
type obj; |
||
obj.* |
obj.*member_name |
||
</source> |
</source> |
||
<source lang="C++"> |
<source lang="C++"> |
||
type *obj; |
type *obj; |
||
obj->* |
obj->*member_name |
||
</source> |
</source> |
||
Line 34: | Line 34: | ||
<source lang="C++"> |
<source lang="C++"> |
||
return_type (type::* |
return_type (type::*member_name)(args...) |
||
</source> |
</source> |
||
Line 41: | Line 41: | ||
<source lang="C++"> |
<source lang="C++"> |
||
type obj; |
type obj; |
||
(obj.* |
(obj.*member_name)(args...) |
||
</source> |
</source> |
||
<source lang="C++"> |
<source lang="C++"> |
||
type *obj; |
type *obj; |
||
(obj->* |
(obj->*member_name)(args...) |
||
</source> |
</source> |
||
Line 52: | Line 52: | ||
[[Category:C++]] |
[[Category:C++]] |
||
[[Category:Programming]] |
[[Category:Programming]] |
||
[[Category:Cheat sheets]] |
Latest revision as of 13:50, 18 April 2020
C/C++
Pointer to function
Declaration:
return_type (*function_name)(args...)
Pointer to member
Declaration:
member_type type::*member_name
Dereference:
type obj;
obj.*member_name
type *obj;
obj->*member_name
Pointer to member function
Declaration:
return_type (type::*member_name)(args...)
Dereference:
type obj;
(obj.*member_name)(args...)
type *obj;
(obj->*member_name)(args...)