+ 1
Difference ( pointer and reference arguments)
During swapping what will be the difference if the function arguments are pointer variables and when they are reference varibles
2 ответов
+ 1
Differences between pointers and references
https://techdifferences.com/difference-between-pointer-and-reference-2.html
http://www.differencebetween.net/technology/difference-between-pointer-and-reference/
0
#include<iostream>
using namespace std;
void swap(int*,int*);
int main()
{
int a=5;
int b=6;
swap(&a,&b);
cout<<"value of a after swapping is :"<<a<<endl;
cout<<"value of b after swapping is :"<<b<<endl;
return 0;
}
void swap(int*p,int*q)
{
int temp;
temp=*p;
*p=*q;
*q=temp;
}
I mean what is the main difference if we use function arguments as int&p, int&q