C++ double type reference as alias for a variable

Description

C++ double type reference as alias for a variable

#include <iostream>
using namespace std;
int main()/*from www . j  a  v  a 2s .  c o  m*/
{
   double total = 20.5;  // declare and initialize total
   double& sum = total;  // declare another name for total
   cout << "sum = " << sum << endl;
   sum = 18.6;           // this changes the value in total
   cout << "total = " << total << endl;
   return 0;
}



PreviousNext

Related