Call by value passes a copy, so changes inside the function do not affect the caller. Call by reference passes the variable itself.
void byValue(int a) { a = 100; }
void byReference(int &a) { a = 100; }
void byPointer(int *a) { *a = 100; }
int main() {
int x = 1;
byValue(x); cout << x; // 1 (copy changed)
byReference(x); cout << x; // 100
x = 1;
byPointer(&x); cout << x; // 100
}
Tip: pass large objects as const T& to avoid copying and to stop accidental changes.