Share
Explore BrainMass

C++ program cpp file and the executable file

1. It is not necessary to name your formal and corresponding actual parameters the same. What are the benefits of doing so?

2. Write a value-returning function that returns the sum of two numbers. Then write the code to produce the same outcome using a void function and passing variables by reference. In what situations might each be used?

Please include any references that will be of value. Thanks a lot.....

Solution Preview

Please see the document file for answers. C++ program cpp file and the executable file are also included.

1. It is not necessary to name your formal and corresponding actual parameters the same. What are the benefits of doing so?

Ans: The parameters in the subprogram header are called formal parameters. Subprograms call statements must include the name of the subprogram and a list of parameters to be bound to the formal parameters of the subprogram. These parameters are called actual parameters.

C++ default parameter passing mechanism is called CALL BY VALUE. Call by value means essentially that the actual parameter value is copied to the formal parameter and the body of the function is evaluated.

Call by value means that changes that are made within a function to its formal parameters are not transmitted in any way to the corresponding actual ...

Solution Summary

C++ program cpp file and the executable file are also included.

$2.19