Thread: pointers

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    8

    pointers

    how i create pointers?
    can you give me an example plz?

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Well since your question is pretty general, my answer will be:

    //to create a regular int variable

    int i;

    //to create a pointer to an int variable

    int *i;

    Notice the *. That's what tells you it's a pointer.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    //using static memory
    int * intPtr = '\0';
    int num = 8;
    intPtr = #
    cout << *intPtr;

    //using dynamic memory
    int * iPtr = new int;
    *iPtr = 5;
    cout << *iPtr;

    Notice that the * operator means pointer when used in declaration and as derefernce operator when used outside of
    declaration and as multiplication operator under other circumstances.

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