SubhanUllah Posted October 27, 2022 Report Posted October 27, 2022 void f(int i) { i = i + 1; } void g(int &i) { i = i + 1; } int main() { int i = 1; f(i); // by value: i is still 1 g(i); // by reference: i is now 2 return 0; } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.