Ask Question
8 August, 04:37

Change the function definition for aNonclassFunction so that aNonclassFunction uses the same memory locations for co as in the calling program.

a) void aNonclassFunction ( * co);

b) void aNonclassFunction (Banana &co);

c) void aNonclassFunction (Banana * co);

d) void aNonclassFunction (&co Banana);

+3
Answers (1)
  1. 8 August, 07:38
    0
    b) void aNonclassFunction (Banana &co);

    Explanation:

    When we want the function to use the same memory location as the memory location for the variable in the calling program we pass that variable by reference. So all the changes done in the function can be refflected on the original variable.

    So you can pass a variable by reference as following : -

    Return_type function_name (Data_Type & variable_name);

    or

    Return_type function_name (Data_Type * variable_name);

    When passing using the * operator you have to derefer in the function to access the value but in case of & you can directly work on the variable.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Change the function definition for aNonclassFunction so that aNonclassFunction uses the same memory locations for co as in the calling ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers