ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> VC++ >> VC++ AllOther
 
 


 

 
 MFC interview questions  MFC Interview Questions (171)
 ATL interview questions  ATL Interview Questions (25)
 COM DCOM interview questions  COM DCOM Interview Questions (35)
 Win32API interview questions  Win32API Interview Questions (28)
 ActiveX interview questions  ActiveX Interview Questions (18)
 VC++ AllOther interview questions  VC++ AllOther Interview Questions (65)
Question
What is the difference between pointer and reference?
 Question Submitted By :: VC++-AllOther
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
1. Pointer can refer NULL, refernce cannot be NULL
2. Pointer can derefernce to another address, Reference
once initialized stays that way till it dies.
3. pointer may not associate with a legitimate memory but
References should associate with certain memory.
4. pointer may not be initialized while created but
refernce has to intialized when it is created.
 
Is This Answer Correct ?    49 Yes 4 No
Treker
 
Answer
# 2
A reference must always refer to some object and,
therefore, must always be initialized;
pointers do not have such restrictions. A pointer can be
reassigned to point to different
objects while a reference always refers to an object with
which it was initialized.
 
Is This Answer Correct ?    30 Yes 5 No
Praveena
 
 
 
Answer
# 3
1)it is not necessary to intialize a pointer at the time of
declaration.like:int a=10; int *p=&a;
u can also do int a=10; int *p; p=&a;
but in the case of reference it is necessary to
intialize a ref.at the time of declaration.like: int
&a=10;bcoz ref.is the secondname(aliase)for an object.means
it always refere an object so it's necessary to initialize
it.
2)u can assign NULL to a pointer.like int *p=NULL; but u
can't assign NULL to a reference.like int
&P=NULL//incorrect.
3)u can create array to a pointer but u can't create
array to a ref.
4) u can use pointer to pointer.but u can't use ref.to ref.
5) pointer is a new variable that contain the address of
another variable.but ref. is a second name (aliase) of the
same variable.
6)to store pointer we require extra memory.but for
reference we don't require extra memory.
 
Is This Answer Correct ?    12 Yes 2 No
Noopur Sharma(m.c.a. R.u)
 
Answer
# 4
http://www.dgp.toronto.edu/~patrick/csc418/wi2004/notes/Poin
tersVsRef.pdf
 
Is This Answer Correct ?    10 Yes 2 No
Hari Krishna
 
Answer
# 5
1)it is not necessary to intialize a pointer at the time of
declaration.like:int a=10; int *p=&a;
u can also do int a=10; int *p; p=&a;
but in the case of reference it is necessary to
intialize a ref.at the time of declaration.like: int
&a=10;bcoz ref.is the secondname(aliase)for an object.means
it always refere an object so it's necessary to initialize
it.
2)u can assign NULL to a pointer.like int *p=NULL; but u
can't assign NULL to a reference.like int
&P=NULL//incorrect.
3)u can create array to a pointer but u can't create
array to a ref.
4) u can use pointer to pointer.but u can't use ref.to ref.
5) pointer is a new variable that contain the address of
another variable.but ref. is a second name (aliase) of the
same variable.
6)to store pointer we require extra memory.but for
reference we don't require extra memory.
 
Is This Answer Correct ?    4 Yes 2 No
Mritunjay Rai
 
Answer
# 6
A reference must always refer to some object and,
therefore, must always be initialized;
pointers do not have such restrictions. A pointer can be
reassigned to point to different
)u can assign NULL to a pointer.like int *p=NULL; but u
can't assign NULL to a reference.like int
&P=NULL//incorrect.
 
Is This Answer Correct ?    3 Yes 1 No
Basudha
 
Answer
# 7
i am also satisfied whose already given answer but major
differnce b/w reference and pointer
1--refrence and pointer both are refer memori address
2--with help of pointer arithmatic calculation done but
pointer not done;
3--refrence tracked by garwage collection but pointer not done;
4--referece must alway refer object which must initialized
 
Is This Answer Correct ?    0 Yes 3 No
Satyendra Singh
 

 
 
 
Other VC++ AllOther Interview Questions
 
  Question Asked @ Answers
 
A file a.cpp & B.cpp are complied & linked together in VC++ file a is something like int a =100;, File B is something like extern a; main() { printf("%d",a); }what will be the output.a)100,b)linker error,c)complier error etc etc. Honeywell 3
How do you specify which control is the buddy control?   2
how i can design a user interface in vc++ for getting inputs from users Path-Finders 1
What function is used to trap all mouse messages?   1
Name the function is used to transfer bitmaps to an output device?   2
How to Use mfc71d.dll not mfc71.dll ?   1
What is a glyph?   2
How can we allow no selection of radio button in grouped radio buttons?   2
Name some examples of the different types of windows found in a Windows application?   4
Name the most commonly used wizards?   2
#include<stdio.h>int(){int a,*b,**c,***d,****e; a=10;b=&a;c=&b;d=&c;e=&c;printf("a=%d b=%u c=%u d=% e=%u",a,b,c,d,e);printf ("%d%d%d\n",a,a+?*b,**c+***d+,****e);return0;}   1
what are the advantages of VC++ design environment   1
 
For more VC++ AllOther Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com