Thread: What does de-referenced mean?

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    30

    Question What does de-referenced mean?

    What does de-referenced mean?

  2. #2
    Unregistered
    Guest
    Code:
    	int num = 100;
    	int* ptr = #
    	cout << *ptr << endl;
    Derefencing the pointer (ptr) gives access to the value of the variable that the pointer is pointing at. If the line was:

    Code:
    cout << ptr << endl;
    then I would just be printing the value of the pointer, ie an address.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Dereferenced means "give the contents of the address pointed to". So if
    int *p = &i;

    Then
    cout<< p <<"\n"; // Prints the address of i
    cout<< *p <<"\n"; // Prints the value of i

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Error in reading from file
    By paulovitorbal in forum C Programming
    Replies: 4
    Last Post: 05-02-2006, 06:15 AM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. 1337 bible, Gen 11
    By Paz_Rax in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 05-20-2005, 09:40 PM