Demonstrates the definition and use of references. : Float « Data Type « C++






Demonstrates the definition and use of references.

Demonstrates the definition and use of references.
 

#include <iostream>
#include <string>
using namespace std;
float x = 10.7F; 
int main()
{
   float  &rx = x; 

   rx *= 2;
   cout << "   x = " <<  x << endl    
        << "  rx = " << rx << endl;   
   const float& cref = x;    
   cout << "cref = " <<  cref << endl; 

   const string str = "I am a constant string!";


   const string& text = str;    
   cout << text << endl;        
   return 0;
} 

           
         
  








Related examples in the same category

1.10.0 would be interpreted as floating point10.0 would be interpreted as floating point
2.Make the result of integer division a floatMake the result of integer division a float
3.Enter hexadecimal digits and a floating-point numberEnter hexadecimal digits and a floating-point number
4.cin to read float in C++cin to read float in C++
5.Float value pointer and int value pointerFloat value pointer and int value pointer
6.Return float type from function
7.Get the square and cube of a float type number