Thread: Pointers

  1. #1
    Registered User
    Join Date
    Feb 2004


    Hi Everyone! Any help on this one would be creatly appreciated :

    I've read the tutorial on the site and checked the FAQ but I still don't understand the purpose of pointers.

    Sorry if this is too much of a newbie question but I'm really stuck.

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Mar 2002
    You could try doing a search of the board using the search button in the upper right hand side of the screen.

    In brief pointers make it easier to pass material/access material. Let's say you have an object that has 1500 bytes of information and you need to pass it to 6 diferent functions during the course of a program. Is it faster to pass all those values, that is all 1500 bytes of information, or just 4 bytes (the size of a pointer).

    Or let's say you have an object that you want to change values of as the result of manipulating data within a function. If you pass all the objects member information by value you don't actually change anything in the original object. If you pass a pointer to the original object, however, you do change the information/data in the original object and not data in a copy of the original object you would change if you passed the object by value instead of by reference using a pointer/reference.

    Or lets say you want to store 100000 CD titles in your store on your computer to keep inventory. The memory in the stack, which is the default memory location for variables used in your program, probably won't let you save that many titles at once. However, gaining access to heap/dynamic/free store (they all mean the same thing) memory may well allow you to store all the titles at once. You don't NEED pointers to keep track of stuff on the stack, but you can do so if you wish. You do NEED to use pointers to keep track of stuff in dynamic memory. That's just the way the system has been set up.

    You'll probably find additional justifications for use of pointers by doing the search.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  3. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM