ALLInterview.com :: Home Page KalAajKal.com
 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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
What is the difference between pass by reference and pass by
value?
 Question Submitted By :: Tribhuvan Sharma
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between pass by reference and pass by value?
Answer
# 1
in pass by referance the parameters are passed as the
address of the variables whereas in pass by value the
variables are directly passed as parameters
 
Is This Answer Correct ?    5 Yes 2 No
Anandan
 
  Re: What is the difference between pass by reference and pass by value?
Answer
# 2
In case of pass by value..the change in the sub-function 
will not cause any change in the main function wheareas in 
pass by reference..the change in the sub-function will 
change the value in the main function..
 
Is This Answer Correct ?    3 Yes 0 No
Subha Raman
 
 
 
  Re: What is the difference between pass by reference and pass by value?
Answer
# 3
passing an object by value is defined by the copy 
constructor of that object's class. This can make pass-by-
value an extremely expensive operation.
 
Is This Answer Correct ?    0 Yes 2 No
P Suresh Kumar
 
  Re: What is the difference between pass by reference and pass by value?
Answer
# 4
in pass by referce function can access original memory 
location of variable so can access value while in case of 
pass by value fuction can copy the value of variable to the 
prototype of its kind of variable so calling funcion can 
access the prototype variable but not the direct original 
variable.
 
Is This Answer Correct ?    1 Yes 0 No
Ganesh
 
  Re: What is the difference between pass by reference and pass by value?
Answer
# 5
in Pass by value; if any change in variable in the sub-
function may not reflected to the main function. where as 
in pass by reference the change in the variable may reflect 
to the original value in the main funtion.

ex : //  Pass by Reference

void Get( int &nIndex){
  nIndex = 10;
}

void main()
{
  int x = 100;
  cout<<Get( x );
}

o/p : 10;

ex : //  Pass by Value

void Get( int nIndex){
  nIndex = 10;
}

void main()
{
  int x = 999;
  cout<<Get( x );
}

o/p : 999
 
Is This Answer Correct ?    2 Yes 0 No
Chinna
 
  Re: What is the difference between pass by reference and pass by value?
Answer
# 6
Pass By Value:

1.It passes the actual value of parameter from the function 
call.
2.Value of the parameter variable in calling functions 
remains unchanged.
3.copy of the variable of actual parameter are made and 
transfer to the formal parameter.

call By Reference:

1.the address of the actual parameter has to be transfered
2.the formal parameter in the function decleretion must of 
pointer type.
3.Any changes in the formal parameter can change the value 
of  actual patameter.
 
Is This Answer Correct ?    1 Yes 0 No
Manila
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
What are virtual functions?  2
how to swap to variables without using thrid variable in java?  3
what is the difference between class and object?  3
Describe what an Interface is and how it?s different from a Class. Spinsys4
What is Method overloading?  4
When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory?? Honeywell12
What is polymorphism? Explain with an example.  7
how to find no of instances of an object in .NET? Infosys1
Can we have a private virtual method ? Ness-Technologies5
Difference between new operator and operator new  2
What are generic functions and generic classes?  2
how do u initialize the constant variables Siemens4
In which Scenario you will go for Interface or Abstract Class?  1
different types of castings Siemens3
What is late bound function call and early bound function call? Differentiate.  2
Tell us about yourself. IBM14
WILL I GET A guaranteed JOB AFTER DOING bsc()IT) and GNIIT from an NIIT CENTRE?? Biocon1
What is the difference between pass by reference and pass by value? TCS6
What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?  1
all about pointers  2
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com