Article: C/C++ Pointers
Article: C/C++ Pointers
http://www.codeproject.com/KB/cpp/pointers.aspx
http://www.cs.cf.ac.uk/Dave/C/node10.html
-
Pointers are variables that point to an area in memory. You define a pointer by adding an asterisk (
*) in front of the variable name (i.e.int *number). -
You can get the address of any variable by adding an ampersand (
&) in front of it, i.e.pNumber = &my_number. -
The asterisk, unless in a declaration (such as
int *number), should be read as “the memory location pointed to by.†-
The ampersand, unless in a declaration (such as
int &number), should be read as “the address of.†-
You can allocate memory using the
newkeyword. -
Pointers MUST be of the same type as the variables you want them to point to; so,
int *numberwill not point to aMyClass. -
You can pass pointers to functions.
-
You must delete memory that you have allocated by using the
deletekeyword. -
You can get a pointer to an array that already exists by using
&array[0];. -
You must delete an array that is dynamically allocated using
delete[], not justdelete.
Courtesy:- http://structuredsand.wordpress.com/
- guru's blog
- Login or register to post comments

