Pointer syntax: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(new page) |
(add category) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== C/C++ == |
|||
=== Pointer to function === |
|||
Declaration: |
|||
<source lang="C++"> |
|||
return_type (*function_name)(args...) |
|||
</source> |
|||
=== Pointer to member === |
=== Pointer to member === |
||
Line 4: | Line 14: | ||
<source lang="C++"> |
<source lang="C++"> |
||
member_type type::* |
member_type type::*member_name |
||
</source> |
</source> |
||
Line 11: | 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 24: | Line 34: | ||
<source lang="C++"> |
<source lang="C++"> |
||
return_type (type::* |
return_type (type::*member_name)(args...) |
||
</source> |
</source> |
||
Line 31: | 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 42: | 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...)