the one function using pointers, the other just returning. What is the purpose of using pointers here as return simplifies the syntax?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
usingnamespace std;
void change(int* var){
*var += 1;
}
int change2(int var){
return var += 1;
}
int main(){
int a = 10;
int b = 22;
change(&a);
b = change2(b);
cout << a << endl;
cout << b << endl;
}