Classes

Why should you generally pass an object of the class to a friend function as a reference parameter?
Choose one answer.

a. if the friend function changes the values of the data member(s)

b. if the friend function will not change the values of the data member(s)

c. It is more efficient to pass the object by reference.

d. A and B

e. A and C

Questions by samah74

Showing Answers 1 - 12 of 12 Answers

harshitha

  • Feb 8th, 2014
 

A and C

  Was this answer useful?  Yes

Friend-ness and reference vs value parameter semantics are completely disconnected issues. You use refernces if you want changes to the parameter to be visible at the call site, and use copy if not. If you dont care then generally, unless the parameter is a very small type, references will be more efficient, but there could potentially be many other considerations. This is a big topic. Some function signatures demand references, eg., copy ctors, perhaps your type is not copyable, etc, etc.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions