Thread: pointers

  1. #1



    If you declare a pointer to hold an objects adress say a float value, there has to be a memory space to hold the specific pointer to store the floats adress. So how come when you ask the compiler for the specific adress of the pointer it is the same as the floats adress, well I know it should be, but isn't the adress of the float stored in the pointer different from the actual memory adress the pointer is stored in? Or are the pointer and float stored in the same memory adress?


  2. #2
    the following code gave me the results below...

    void main(void)
       float* pFloat;
       float  myFloat;
       pFloat = &myFloat;
       myFloat = (float)10.01;
       cout << "\nAddress of &pFloat:  "  << &pFloat;
       cout << "\nAddress of pFloat:   "  << pFloat;
       cout << "\nAddress of &myFloat: "  << &myFloat;
       cout << endl;
    Address of &pFloat: 0x0066FDF4
    Address of pFloat: 0x0066FDF0
    Address of &myFloat: 0x0066FDF0
    Press any key to continue

    Indicating that the pointer is store at a different location than
    say for instance the memory block 10 holds the value 11
    the memory block 11 holds the value of the actual float 10.01 or whatever.... I used 10 and 11 to simplify the explanation...

  3. #3


    So the adress of the pointer and the one it holds are two different things.

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
    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