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
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With