View Full Version : C++ Reference/Pointer Tutorial

08-24-2008, 09:17 PM
I have created this reference/pointer tutorial for all C++ users who may or yet may have not completely understood the usage, meaning, and convenience of references and pointers and not to replace the many useful C++ programming books.

Alright, let's get to the point:

references are basically objects that are used in C++ of which refer to memory locations on the heap. It is actually pretty simple. If you change a reference, it will change the (variable-of-which-is-referred-to-by the-reference)'s value.

pointers are basically objects that are used in C++ of which point to memory locations on the stack. It is actually pretty simple. If you give a pointer a memory address, the value of the memory cubby is equivalent to the memory address's value in which is pointed to by the pointer.

These are very helpful and useful objects that are used in programming.


08-24-2008, 09:36 PM
Seen better...

08-27-2008, 01:51 AM
I'm sure you have...:):(:confused:<:mad:>:p

In fact, I've only been with C++ for a year. Any suggestions on how to teach? I understand much, but I do not know how to preach my knowledge. Well, that is.


08-27-2008, 06:04 AM
You could perhaps go into some form of detail :) Also, you're wrong about references: they point to exactly the same places as pointers, which can be on the stack or the heap: the stack is used for statically-assigned memory, while the heap is used for dynamically-assigned memory (allocated with malloc() and friends). The sole purpose of references is to be safer and more convenient by removing the need to work explicitly with pointers, but they're basically just pointers behind the scenes.

08-27-2008, 09:02 PM
Thanks!! Where do you learn this stuff? Books? College? By the way, if you went to college, which one and what did you get degrees in?


P.S. <:)>:(:mad::confused: - You're probably laughing your head off now, unless (multiple reasons)

P.P.S. Thank you for correcting me. If you hadn't, the whole world would have seen my mistake. (By the whole world, I imply the countries that have access to this website)

08-27-2008, 09:17 PM
The Internet. No, I'm a 'high-school' drop-out.

08-27-2008, 09:18 PM
You are saying you didn't go to college? And what do you mean by 'high-school' dropout?

What is Twey? Is that a name or catchy username?


P.S. Where on the internet? Specific websites?

08-27-2008, 09:56 PM
You are quite correct, and I meant that here in England we do not in fact have 'high-school' as the term is usually used. 'Twey' is both my username and nickname.

I can't give a list of everything, no, but you might enjoy the C++ standard draft (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf).

08-27-2008, 10:02 PM
Thank you very much. One last unimportant question: do you have an english accent?

(doo yoo hauv un eenglish aucksent)?


08-27-2008, 10:20 PM
Rather unsurprisingly. My accent is notable only by virtue of being exceptionally generic. I believe it to be more or less English, yes, although fellow English-speakers often have difficulty placing it.

What was that impression supposed to be? Sounded kind of Austrian.

08-27-2008, 10:36 PM
What do you mean Austrian - impression?


P.S. I am an American

08-28-2008, 01:10 AM
(doo yoo hauv un eenglish aucksent)?This impression.

n 8: an impressionistic portrayal of a person; "he did a funny
impression of a politician"

08-28-2008, 02:19 AM
Here the old people have a strange accent... It's a mix between British and Irish. It's interesting, to say the least.

08-28-2008, 10:33 PM
Ok. Thanks for all of the clarity. Thus ends my tutorial.