Switch to full style
For C/C++ coders discussions and solutions
Post a reply

The using of pointers between two variables (Swaping)

Sun May 25, 2008 5:23 pm

This code let you see the using of the pointers for the integer a, b and how we swap these pointers
Code:
#include<iostream.h>
void main()
{
    int a=5,b=4;

   int &refa=a,&refb=b;
   int temp;
    cout<<&refa<<&refb<<endl;
   temp=refa;
   refa=refb;
   refb=temp;


    cout<<&refa<<&refb<<endl;
}

:wave:



Post a reply
  Related Posts  to : The using of pointers between two variables (Swaping)
 Local variables vs Instance variables     -  
 Swap Using Pointers     -  
 Arrays using Pointers     -  
 Types of Pointers in C++     -  
 How to use pointers and what it means     -  
 Basic Pointers     -  
 pointers to derived types     -  
 Passing Pointers to function example     -  
 References confuse me. How do they differ from pointers?     -  
 PHP Variables     -  

Topic Tags

C++ Variables, C++ Basics