C ++ - additional arguments by reference

I have a C ++ exam and I have been solving a few of the past years. I have this question in one of them:

The function calculates the prysm volume. Skipped arguments are height, depth, and width. Arguments and return value double. Depth is optional and should have a default value of 10. Hypothesis 1: All parameters are passed a value

I replied double volume_prysm(const double width, const double height, const double depth = 10);

Hypothesis 2: All parameters are passed by reference

How to define a reference parameter so that it defaults to 10?

Thank you for your time!

PS: Sorry you did not translate

+3
source share
1 answer

, , const:

double volume_prisma(const double& largura, ..., const double& depth = 10);
+4

Source: https://habr.com/ru/post/1753002/


All Articles