Give an example of when a parameter should be a reference type. Give an example of when a parameter should not be a reference
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:6| Question number:14
All Answers
total answers (1)
Reference parameters
- Functions must use reference parameters to operate on objects of a type that cannot be copied.
- Functions prefer to use reference parameters to operate on objects of large class types or large containers.
- Functions should use reference parameters to return additional information via the reference parameters.
Nonreference parameters
- Functions should use nonreference parameters when the value of the parameters may changed but should not affect the objects passed to the function.
need an explanation for this answer? contact us directly to get an explanation for this answer