Ask Question
12 June, 13:47

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);

+2
Answers (1)
  1. 12 June, 14:17
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers