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
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
write a program that takes input in digits and display the result in words from 1 to 1000
What is destructor example?
Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?
What is destructor give example?
What is difference between oop and pop?
What is protected in oop?
How do you define a class in oop?
What is pure oop?
What is polymorphism in oops?
What is the main purpose of inheritance law?
Write a program to reverse a string using recursive function?
What is a class oop?
Can static class have constructor?
Can bst contain duplicates?