Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Pointer (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Pointer declaration syntax overview==== These pointer declarations cover most variants of pointer declarations. Of course it is possible to have triple pointers, but the main principles behind a triple pointer already exist in a double pointer. The naming used here is what the expression <code>typeid(type).name()</code> equals for each of these types when using [[g++]] or [[clang]].<ref>{{cite web|url=https://linux.die.net/man/1/c++filt|title=c++filt(1) - Linux man page}}</ref><ref>{{cite web|url=http://refspecs.linux-foundation.org/cxxabi-1.83.html#mangling|title=Itanium C++ ABI}}</ref> <syntaxhighlight lang="C"> char A5_A5_c [5][5]; /* array of arrays of chars */ char *A5_Pc [5]; /* array of pointers to chars */ char **PPc; /* pointer to pointer to char ("double pointer") */ char (*PA5_c) [5]; /* pointer to array(s) of chars */ char *FPcvE(); /* function which returns a pointer to char(s) */ char (*PFcvE)(); /* pointer to a function which returns a char */ char (*FPA5_cvE())[5]; /* function which returns pointer to an array of chars */ char (*A5_PFcvE[5])(); /* an array of pointers to functions which return a char */ </syntaxhighlight> The following declarations involving pointers-to-member are valid only in C++: <syntaxhighlight lang="Cpp"> class C; class D; char C::* M1Cc; /* pointer-to-member to char */ char C::*A5_M1Cc [5]; /* array of pointers-to-member to char */ char* C::* M1CPc; /* pointer-to-member to pointer to char(s) */ char C::** PM1Cc; /* pointer to pointer-to-member to char */ char (*M1CA5_c) [5]; /* pointer-to-member to array(s) of chars */ char C::* FM1CcvE(); /* function which returns a pointer-to-member to char */ char D::* C::* M1CM1Dc; /* pointer-to-member to pointer-to-member to pointer to char(s) */ char C::* C::* M1CMS_c; /* pointer-to-member to pointer-to-member to pointer to char(s) */ char (C::* FM1CA5_cvE())[5]; /* function which returns pointer-to-member to an array of chars */ char (C::* M1CFcvE)() /* pointer-to-member-function which returns a char */ char (C::* A5_M1CFcvE[5])(); /* an array of pointers-to-member-functions which return a char */ </syntaxhighlight> The <code>()</code> and <code>[]</code> have a higher priority than <code>*</code>. <ref>Ulf Bilting, Jan Skansholm, "Vägen till C" (the Road to C), third edition, page 169, {{ISBN|91-44-01468-6}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)