Pointers

This is a discussion on Pointers within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Are pointers necessary in C++? Are pointers useful in C++? (as opposed to references only)...

  1. #1
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493

    Pointers

    Are pointers necessary in C++?
    Are pointers useful in C++?

    (as opposed to references only)

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    I think so, but shouldn't this be in the C++ forum?

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >> Are pointers necessary in C++?

    in the most simple cases, no. but for any practicle program pointers are necessary ( you cant even have an array with out a pointer)

    >> Are pointers useful in C++?

    yes, extremely. usefull for so many reasons i cant even begin to list them.

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136

    Re: Pointers

    Originally posted by ygfperson
    Are pointers necessary in C++?
    Are pointers useful in C++?

    (as opposed to references only)
    Function pointer, void pointer, if the location being pointed to needs to be changed

  5. #5
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    >Are pointers necessary in C++?
    Yes. References remove most needs for pointers, but in just about any nontrivial program you'll find yourself using them liberally.

    >Are pointers useful in C++?
    Same question, different words. See above.

    >(as opposed to references only)
    What if you want to change where a reference refers? Or use a "null" reference?

    >Function pointer
    You can have references to functions, they just look funny because nobody's used to them.
    p.s. What the alphabet would look like without q and r.

  6. #6
    Registered User rick barclay's Avatar
    Join Date
    Aug 2001
    Posts
    835
    I always thought pointers were a way to manage memory, which
    would make them useful.
    No. Wait. Don't hang up!

    This is America calling!

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    46
    Absolutely, especially if your gonna do low-level type stuff.
    mooooo@cooowwww.com

  8. #8
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220

    Re: Pointers

    Originally posted by ygfperson
    Are pointers necessary in C++?
    Are pointers useful in C++?

    (as opposed to references only)
    I suppose you could program without them, if you just wanted to print something on screen.

    No wait, you need pointers for that.

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
      cout << "Hello, pointer world" << endl;  // The stuff in the speech marks is addressed by a pointer.
      return 0;
    }

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, 06:59 AM
  2. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 11: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21