what's inadequacy between func(int ¶m) func(int *param)?
in following code, both amp_swap()
star_swap()
seems doing same thing. since someone move over other? comparison footnote why? only matter taste?
#include <iostream>
using namespace std;
void amp_swap(int &x, int &y)
{
int temp = x;
x = y;
y = temp;
}
void star_swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}
int main()
{
int = 10, b = 20;
cout << "using amp_swap(): " << endl;
amp_swap(a, b);
cout << "a = " << << ", b = " << b << endl;
cout << "using star_swap(): " << endl;
star_swap(&a, &b);
cout << "a = " << << ", b = " << b << endl;
relapse 0;
}
thanks your time!
see also
Comments
Post a Comment