Thread: pointers

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    196

    pointers

    ok now i can fairly welly use pointers to a minimum but i cant for the life of me figure out what its usefull for i mean like what can it possibly do to advance my application

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Well this has been discussed many of times. I am going to say they are not generally usefull in your everyday C++ programming because of std:: containers and references. But there are times that you do have to get down and dirty with some pointer action. It is that fun naughty kind of action too unless you are NULL(0 for you nitpickers) then it just goes downhill. Anyways they are one of those things where it doesn't seem usefull until you need them .
    Woop?

  3. #3
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    pointers are traditionally used to avoid copying large objects and to manage arrays.

    Code:
    class Huge
    {
        int MassiveArray[10000];
    };
    
    void func(Huge h) // have to copy 40000 bytes here! not cool
    {
    }
    
    void func(Huge *pH) // only have to copy 4 bytes. much better
    {
    }
    their use in this context has been pretty much superseded by references, but there are still cases where pointers are required, for example if you want to pass a NULL value or use dynamic memory
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

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 Cprogramming.com
    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