a. What does the following short program display and why? #include using namespace std; double up(double x)

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) {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;
}

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

C++ Primer Plus

ISBN: 9780321776402

6th Edition

Authors: Stephen Prata

Question Posted: