What do you mean by call by value and call by reference?
Answer Posted / hr@tgksolutions.com
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 jump statement in C++?
how can i access a direct (absolute, not the offset) memory
address?
here is what i tried:
wrote a program that ask's for an address from the user,
creates a FAR pointer to that adress and shows it. then the
user can increment/decrement the value in that address by
pressing p(inc+) and m(dec-).
NOW, i compiled that program and opened it twice (in 2
different windows) and gave twice the same address to it.
now look what happen - if i change the value in
one "window" of the program, it DOES NOT change in the
other! even if they point to the same address in the memory!
here is the code snippet:
//------------------------------------------------------
#include What is a sequence in c++? what is the difference between overloading & overriding? give example. What is an accessor in c++? Must accepts "Maestro Cards"
Tax for bike should be less than 15
Total number of lanes is more than 10
Must provides monthly pass
Write a method:
boolean isGoodTollBridge(String[] cardsAccepted, String[] tollTax, boolean hasMonthlyPass, int numberOfLanes);
String[] cardsAccepted A String array of names of card types accepted for payment of toll tax, it can be null if the toll does not accept any card
String[] tollTax A String array of toll tax chart (say “Train : 300â€Â,â€ÂBullCart : 10â€Â)
boolean hasMonthlyPass This parameter defines whether there is any monthly pass available or not
int numberOfLanes This parameter defines the number of lanes for each side What is a storage class? Mention the storage classes in c++. What is the difference between reference and pointer? What is tellg () in c++? Is facebook written in c++? What is the use of 'using' declaration in c++? Explain register storage specifier. What is constructor c++? What it is and how it might be called (2 methods). How does the copy constructor differ from the assignment operator (=)?