Thread: Pointers

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    1

    Question Pointers

    What is the diff between * and ->

    Thanks in adv.

  2. #2
    Unregistered
    Guest
    -> is used to abbreviate a pointer to a member of a structure:
    (*p_part).number = p_part->number

  3. #3
    *
    Guest
    You don't normally compare the two. * is a symboling telling the compiler that you want to go *indirectly* through a variable (making it a pointer).

    -> on the other hand, is used for reference the fields of a structure, when you only have a pointer to the structure, not the actual structure itself, to work with.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Don't forget there's two different versions of *. One is for referencing, or declaring the pointer like has been mentioned, and one is for retrieving the value stored in the memory address contained in the pointer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MergeSort with array of pointers
    By lionheart in forum C Programming
    Replies: 18
    Last Post: 08-01-2008, 10:23 AM
  2. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 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