Description
Passing arguments is a standard method used in all programming languages.Explain the difference when you use these two (2) methods: passing an argument by value and passing data by reference.Provide an example of each type.
Explanation & Answer
Passing by value actually passes a copy of an argument.
Passing by reference actually passes the address of an argument.
So the differences is:
1) when passing by value an argument always remains unchanged, when by reference can be changed;
2) if an argument is class or structure, then for passing by value a copy constructor is necessary (direct or indirect);
3) If an argument is large (structure) then passing by value requires more memory.
Review
Review
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Similar Content
Related Tags
The Mayor of Casterbridge
by Thomas Hardy
Big Magic
by Elizabeth Gilbert
How to Win Friends and Influence People
by Dale Carnegie
The Turn of the Screw
by Henry James
The Secret Garden
by Frances Hodgson Burnett
We Were Eight Years in Power
by Ta-Nehisi Coates
The Visible Filth
by Nathan Ballingrud
Uncle Tom's Cabin
by Harriet Beecher Stowe
Anthem
by Ayn Rand