What is the difference between pass by reference and pass by
value?
Answer Posted / chinna
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 ? | 29 Yes | 17 No |
Post New Answer View All Answers
Can destructor be overloaded?
What are main features of oop?
What is encapsulation and abstraction? How are they implemented in C++?
What is class encapsulation?
Why is polymorphism needed?
write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).
Why do pointers exist?
Can abstract class have normal methods?
Which method cannot be overridden?
write a program to find 2^n+1 ?
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
What is object in oop with example?
What is the difference between a mixin and inheritance?
Why is abstraction used?
What is polymorphism and example?