Question: For the following short program, which function calls are errors and why? For the valid calls, what does the reference argument refer to? #include using

For the following short program, which function calls are errors and why? For the valid calls, what does the reference argument refer to?
#include
using namespace std;
double up(double x) { return 2.0* x;}
void r1(const double &rx) {cout << rx << endl;}
void r2(double &rx) {cout << rx << endl;}
void r3(double &&rx) {cout << rx << endl;}
int main()
{
double w = 10.0;
r1(w);
r1(w+1);
r1(up(w));

r2(w);
r2(w+1);
r2(up(w));
r3(w);
r3(w+1);
r3(up(w));
return 0;
}

Step by Step Solution

3.44 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

For the following short program the function calls r1w r1w1 and r1upw are valid while the function ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction Java Program Questions!