rvref.cpp 585 B

123456789101112131415161718
  1. // rvref.cpp -- simple uses of rvalue references
  2. #include <iostream>
  3. inline double f(double tf) {return 5.0*(tf-32.0)/9.0;};
  4. int main()
  5. {
  6. using namespace std;
  7. double tc = 21.5;
  8. double && rd1 = 7.07;
  9. double && rd2 = 1.8 * tc + 32.0;
  10. double && rd3 = f(rd2);
  11. cout << " tc value and address: " << tc <<", " << &tc << endl;
  12. cout << "rd1 value and address: " << rd1 <<", " << &rd1 << endl;
  13. cout << "rd2 value and address: " << rd2 <<", " << &rd2 << endl;
  14. cout << "rd3 value and address: " << rd3 <<", " << &rd3 << endl;
  15. // cin.get();
  16. return 0;
  17. }