Trailing default parameters check – CSKC
Sign In

Search

Solved Problem! #CPP#2666    siteicon   siteicon  

Problem Statement - Trailing default parameters check

A c++ program given here has some errors. Please correct the errors to make it a working program. Assume any data values required to make it working correctly.

TC++ #2666

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

Solution


float volbox(float s1=10,float s2,float s3=10);
Here parameter for s1 has a default value but s2 doesn’t have and s3 again has a default value. The rule is that if any parameter has a default value then all trailing parameters must have a default value. So if in this example this line is made as follows.
float volbox(float s1=10,float s2=10,float s3=10);
It will work. Optionally one can remove default value of last parameter s3 and make it work. This will work even when all default values are removed.


Share

Created: 16-Jan-2018 14:38 | Updated: 16-Jan-2018 15:59|