Using a reference as a synonym


#include <iostream.h>

void main()
{    int n=44;
    int& rn=n;  // r is a synonym for n
    cout << "n = " << n << ", rn = " << rn << endl;
    --n;
    cout << "n = " << n << ", rn = " << rn << endl;
    rn *= 2;
    cout << "n = " << n << ", rn = " << rn << endl;
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|