Ask Question
Today, 07:54

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

+4
Answers (1)
  1. Today, 11:10
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers