Reputation: 5086
I have an exam on C++ coming up, and I'm solving a few ones from past years. I have this question in one of them:
A function calculates the volume of a prysm. Arguments passed are height, depth and width. Arguments and return value are doubles Depth is optional and should default to 10. Hypothesis 1: All parameters are passed by value
I answered double volume_prysm(const double width, const double height, const double depth = 10);
Hypothesis 2: All parameters are passed by reference
How can I define a reference parameter in order for it to default to 10?
Thanks for your time!
PS: Sorry y'all for not translating
Upvotes: 3
Views: 2406
Reputation: 98984
I don't know if that is what the question was aiming at, but temporaries can be bound to const references:
double volume_prisma(const double& largura, ..., const double& depth = 10);
Upvotes: 4