What do you mean by call by value and call by reference?
Answer Posted / glibwaresoftsolutions
A common topic that often appears in C++ interview questions is the difference between call by value and call by reference.
• Call by Value in C++: In the call-by-value method, function arguments are passed by copying the value of the actual parameter.
• This ensures that the original values remain unchanged since a separate copy of the value is created for the function's parameters.
• Call by Reference in C++: In the call-by-reference method, the memory address (or reference) of the actual parameter is passed to the function.
• This allows direct access to and modification of the original values.
• Both the actual and formal parameters refer to the same memory address, so any changes made to the parameters within the function are directly reflected in the original values outside the function.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the importance of mutable keyword?
Why do we use vector in c++?
Why is c++ called oops?
What do you mean by inheritance in c++? Explain its types.
What is constructor c++?
What is pure virtual function? Or what is abstract class?
What is general format for a prototype?
What is the default access level?
What is the iunknown interface?
What do you understand by pure virtual function? Write about its use?
Is dev c++ a good compiler?
What do you mean by ‘void’ return type?
Is c# written in c++?
How does java differ from c and c++?
Write a program which uses functions like strcmp(), strcpy()? etc