Pointer syntax: Difference between revisions

From vegard.wiki
Jump to navigation Jump to search
Content added Content deleted
(clarify names)
Line 6: Line 6:


<source lang="C++">
<source lang="C++">
return_type (*name)(args...)
return_type (*function_name)(args...)
</source>
</source>


Line 14: Line 14:


<source lang="C++">
<source lang="C++">
member_type type::*member
member_type type::*member_name
</source>
</source>


Line 21: Line 21:
<source lang="C++">
<source lang="C++">
type obj;
type obj;
obj.*member
obj.*member_name
</source>
</source>


<source lang="C++">
<source lang="C++">
type *obj;
type *obj;
obj->*member
obj->*member_name
</source>
</source>


Line 34: Line 34:


<source lang="C++">
<source lang="C++">
return_type (type::*member)(args...)
return_type (type::*member_name)(args...)
</source>
</source>


Line 41: Line 41:
<source lang="C++">
<source lang="C++">
type obj;
type obj;
(obj.*member)(args...)
(obj.*member_name)(args...)
</source>
</source>


<source lang="C++">
<source lang="C++">
type *obj;
type *obj;
(obj->*member)(args...)
(obj->*member_name)(args...)
</source>
</source>



Revision as of 10:31, 10 February 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...)