Sunday, July 31, 2011

Creating and Using References in C++

http://fwallpapers.com/files/images/c-programming-language.jpg


#include <iostream>
 
 int main()
 {
     int  intValue;
     int &intReference = intValue;
 
     intValue = 5;
     std::cout << "intValue: " << intValue << std::endl;
     std::cout << "intReference: " << intReference << std::endl;
 
     intReference = 7;
     std::cout << "intValue: " << intValue << std::endl;
     std::cout << "intReference: " << intReference << std::endl;
     return 0;
 }
 
Output:
intValue: 5
intReference: 5
intValue: 7
intReference: 7
 
Read More..... 
 
via[java2s] 

0 comments:

Post a Comment