|
| mborja (9) | | ||||||
| Note: While reading through this short overview of pointers in C++, you will find some code samples that are given to help illustrate and document the concepts being explained herein. Parts of code samples are not intended to be conclusive, compile ready or free of type declaration or initialization errors. If you've ever worked with shortcuts (Windows) or symbolic links (UNIX), you should find pointers a relatively easy concept. There are references and then there are pointers (which looks at the value being referenced). Though very similar in context, there is a slight distinction between the proper usage and interpretation of references and the proper usage and interpretation of pointers. To illustrate this point, if you can imagine having a shortcut on your desktop in Windows. This shortcut can be considered a pointer as it "points" directly to the target file itself. A reference would then be the actual location (or container) of our target file, similar to a mailing address (i.e. where can we find our target?) When working with pointers, there are two operators with very specific functions to keep into consideration: REFERENCE: The first is the ampersand (&) which precedes an existing variable or function and returns its actual address (reference) in memory. For example:
POINTER: The other operator is an asterisk (*) preceding our address variable, returning the value pointed to by a reference. For example:
Keep in mind that it is important to observe data types as they must be treated the same as standard variables in C++.
| |||||||
| guestgulkan (1006) | |
| We have had several articles on pointers already. | |
| kempofighter (491) | |
| I do see a few but they are far from comprehensive and do not cover all possible cases. There is a tutorial here, which is fairly comprehensive. http://www.cplusplus.com/doc/tutorial/pointers.html We could probably use a few more articles on pointers that discuss more specific issues. Repetition is the key to learning. So long as the information is accurate, I have no problem with some redundancy. | |
Last edited on | |
| guestgulkan (1006) | |
| Those areprobably the ones I was thinking about http://www.cplusplus.com/forum/articles/418/ http://www.cplusplus.com/forum/articles/10/ http://www.cplusplus.com/forum/articles/9/ http://www.cplusplus.com/forum/articles/8/ (Please note I didn't say don't continue with the article) | |
| riffraff (2) | |
| When we are talking about pointers, is there anything about function pointers: member pointers: pointers to member functions: and for g++ users the pmf-conversion: | |
Last edited on | |
This topic is archived - New replies not allowed.

