Results 1 to 4 of 4

Thread: Difference between pointer and reference

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Difference between pointer and reference

    Can nay one tell me what is the difference between (pointer and reference ) the entries below:
    Code:
    int  n3 = new int (13); 
    and 
    int * & n3 = new int (13);
    thank you

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Difference between pointer and reference

    A reference can be thought of as a special type of pointer with certain restrictions. references have to be initialized at the time of declaration and cannot be changed in the code later , whereas this does'nt hold true with the pointers.Pointers and Reference looks similar but there are some difference between both of them.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Difference between pointer and reference

    Pointer maynot associate with a legitimate memory but refernces should associate with certain memory.A pointer can be re-assigned any number of times while a reference can not be reassigned after initialization. Reference cannot be changed whereas pointer value can be changed. Actually, const pointer = reference.A pointer can point to NULL while reference can never point to NULL.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Difference between pointer and reference

    POINTER

    Code:
    int b = 11;
    
    int *P = &b; //It is not necessary 
    
    Another way is :
    
    int b = 11;
    
    int *q;
    q = &b; 
    
     You can create the array of Pointer,assign NULL to the pointer like
    
    int *q = NULL;
    REFERENCE
    Code:
    int &b = 10;
    
    int &b; 
    
    int &b = NULL; //Error
    
     You can not use reference to reference.

Similar Threads

  1. Changing Stylus pointer to normal Pointer in Tablet PC
    By Kelley in forum Portable Devices
    Replies: 3
    Last Post: 21-06-2011, 07:22 PM
  2. Can we use pointer in C#?
    By Zoey Mod in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 10:49 AM
  3. Differentiation between void pointer and null pointer
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 18-01-2010, 12:11 PM
  4. Pointer to structure in C
    By Jamaima in forum Software Development
    Replies: 3
    Last Post: 08-10-2009, 03:30 PM
  5. Replies: 4
    Last Post: 25-02-2009, 07:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,427,743.13343 seconds with 16 queries