For each of the three following declarations of combine, explain what happens if we call i.combine(s), where i is a Sales_data and s is a string
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:7| Question number:49
All Answers
total answers (1)

C++ programming
(a)
`Sales_data &combine(Sales_data);`The code works correct. It will first convert`s`to`Sales_data`, then copy that temporary into the parameter of`combine`.(b)
`Sales_data &combine(Sales_data&);`The code is wrong. It will first convert`s`to`Sales_data`, then pass the reference to that temporary into the parameter of`combine`, but passing a reference to a temporary is error.(c)
need an explanation for this answer? contact us directly to get an explanation for this answer`Sales_data &combine(const Sales_data&) const;`The code could not compile, because it should not be a const member function. It will first convert`s`to`Sales_data`, then pass the const reference to that temporary into the parameter of`combine`.