Question: a. What does the following short program display and why? #include using namespace std; double up(double x) { return 2.0* x;} void r1(const double &rx)

a. What does the following short program display and why?
#include
using namespace std;
double up(double x) { return 2.0* x;}
void r1(const double &rx) {cout << “const double & rx\n”;}
void r1(double &rx) {cout << “double & rx\n”;}
int main()
{
double w = 10.0;
r1(w);
r1(w+1);
r1(up(w));
return 0;
}
b. What does the following short program display and why?
#include
using namespace std;
double up(double x) { return 2.0* x;}
void r1(double &rx) {cout << “double & rx\n”;}
void r1(double &&rx) {cout << “double && rx\n”;}
int main()
{
double w = 10.0;
r1(w);
r1(w+1);
r1(up(w));
return 0;
}
c. What does the following short program display and why?
#include
using namespace std;

double up(double x) {return 2.0* x;}
void r1(const double &rx) {cout << “const double & rx\n”;}
void r1(double &&rx) {cout << “double && rx\n”;}
int main()
{
double w = 10.0;
r1(w);
r1(w+1);
r1(up(w));
return 0;
}

Step by Step Solution

3.43 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a The output from the first three lines are const double rx ... 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!