Explore BrainMass

Explore BrainMass

    Basics of Passing Arguments in C++

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Use the program, Passing-by-Value, on Ex5_02 of the text and the program, Passing-by-Reference, on Ex5_07 as a starting point for this assignment.

    Write a similar program, but change the code to pass two variables to the function call rather than one.

    Answer the following questions after completing both programs:

    - What is the purpose of the function header?
    - How may you identify the body of a function?
    - What does the return statement do?

    Note. Do not combine these programs into one program.

    © BrainMass Inc. brainmass.com March 5, 2021, 1:01 am ad1c9bdddf


    Solution Preview

    The attached program (main.cpp) shows how to pass two arguments to a
    function both by reference and by value.

    The function headers show the return type, the function name, and the
    list of arguments that the function takes. For example:

    int incr10byref(int& num1,int& num2)

    This indicates that the function named "incr10byref" returns an
    integer and takes to integer ...

    Solution Summary

    This solution shows how to pass arguments both by value and by reference in C++. It provides complete C++ program to illustrate this.