Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[C++] Pointers
07-03-2011, 01:32 AM (This post was last modified: 07-03-2011 01:36 AM by Smithy.)
Post: #1
[C++] Pointers
So, you want to learn about pointers? Well you have come to the right place.

A computer does not understand letters or names that you specify in your code. The computer refers to memory addresses to access said information. Think of a pointer like a variables, but rather than storing an integer or a string it simply stores a memory address. A memory address of another variable to be specific.

The following code will declare a new pointer. The syntax is as follows
<type> *<name> = <value>;
Code:
int *number_Pointer; // A pointer with no current value

Now, we don't want an empty pointer do we? So begin by setting up a normal integer.
Code:
int number = 5; // An integer variable with a value of 5.

Now we want to store the memory address of "number" inside of our pointer.
Code:
number_Pointer = &number;

Our pointer now is "pointing" to the location in memory of our integer.
[Image: 6af53e0d1f168164c415c81985aac0d5.png]

Pointers are very useful. In memory management of course, but also other things. You can use pointers to pass data between functions and to change the value of different variables.

Please PM me with any questions.

Contact me for C++, C# or VB.NET assistance.
Find all posts by this user
Quote this message in a reply
07-04-2011, 06:30 PM
Post: #2
RE: [C++] Pointers
Thanks a lot for all this useful infomation.
I'm currently learning C++ so this is great!
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)