0
Bob-
7y

I can't understand what Pointers do in C++, help?

Comments
  • 3
    Do you know how the Stack and Heap work?

    To (over)simply...

    In your system Memory, variables of primitive types (int, float, long, etc.) are stored on the Stack. Object types are stored in the Heap, and Addresses to them are stored in the Stack.

    A pointer is basically the Heap Memory Address of an object. (If you try to print it out, you get something like 0x029C437F) It is not the object itself.

    EDIT: Therefore, to use the object in some way, you must "dereference" the pointer, which basically means actually go to that address and find the Actual object for use. pointers are basically almost like Links you can follow to get to an instance of an object in memory. You must actually click on the link and follow it to where it goes for it to be useful.

    If that makes sense..

    DOUBLE EDIT: I'm definitely no expert, so please correct me if I'm wrong
Add Comment