Function: reference version and pointer version
#include <iostream> using namespace std; void referenceVersion(int &i); // reference version void pointerVersion(int *i); // pointer version int main() { int i = 10; int j = 20; referenceVersion(i); pointerVersion(&j); cout << i << ' ' << j << '\n'; return 0; } // using a reference parameter void referenceVersion(int &i) { i = -i; } // using a pointer parameter void pointerVersion(int *i) { *i = - *i; }