Hello, everyone I'm Corinne, who started C++ 2 days ago I tried coding as below to implement call by value reference directly.
void Exchange1(int a, int b) { int temp1;
temp1 = a;
a = b;
b = temp1;
}
void Exchange2(int* x, int* y) { int temp2;
temp2 = *x;
*x = *y;
*y = temp2;
int main() { int a, b, x, y;
a = 1;
b = 2;
x = 3;
y = 4;
printf("Before Call-by-value: %d, %d\n", a, b);
Exchange1(a, b);
printf("After Call-by-value: %d, %d\n", a, b);
printf("before swap: %d %d\n", x, y);
Exchange2(x, y);
printf("After swap: %d %d\n", x, y);
return 0;
}
void
No matter how many functions you define, it's the developer's mind. It's just that if you create functions that you don't need, you can'
And if you put the parameter as a pointer, you have to put the address value of the variable like Exchange2 (&x, &y).
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.