C++ Functions of the parameters to be passed by reference

Posted: October 23, 2014 in C++

using namespace std;
void degistir1( int &x, int &y ) // Referans ile parametre aktarımı
int gecici;
gecici = x;
x = y;
y = gecici;
void degistir2( int *x, int *y )
int gecici;
gecici = *x;
*x = *y;
*y = gecici;

int main()
int a, b;
a = 12;
b = 27;
cout<< “degistir1 before a: “<<a<<” b : “<<b<<endl;
degistir1(a, b);
cout<< “degistir1 after a: “<<a<<” b : “<<b<<endl;

cout<< “degistir2 before a: “<<a<<” b : “<<b<<endl;
degistir2(&a, &b);// Argumanları aktarırken, baslarina & konur
cout<< “degistir2 after: a: “<<a<<” b : “<<b<<endl;
return 0;



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s