+ 1

Can someone please explain this ?

int f1(int x,int&y){ x=99; y=99; return x,y; } int main() { int a=20,b=40; f1(a,b); cout<<a<<b<<endl; return 0; } //Out 2099

3rd May 2019, 8:06 AM
San Anemos
San Anemos - avatar
4 Answers
0
A не мог бы ты написать на русском ?
3rd May 2019, 9:01 AM
San Anemos
San Anemos - avatar
+ 3
How would I do that in C? Like this: void f1 (int x,int *y); int main() { int a=20, b=40; f1(a, &b); printf("%d%d", a, b); return 0; } void f1 (int x, int *y) { x=99; *y=99; } Or is there a better way?
3rd May 2019, 10:02 AM
Thoq!
Thoq! - avatar
0
"int x" is the argument of the function with the name of the variable "x" of the type integer which is assigned the value "99"; "int& y" is the argument of the function with the name of the address in which the value "99" of the variable "y" is stored. The variable “a” replaces the variable “x” with the value “99” to “20”, and “b” replaces the address name from “y” with “b” in which the value “99” is stored. RU: «int x» - аргумент функции с именем переменной «x» типа integer, которому присваивается значение «99»; «int& y» - это аргумент функции с именем адреса, в котором хранится значение «99» переменной «y». Переменная «a» заменяет переменную «x» значением с «99» на «20», а «b» заменяет имя адреса с «y» на «b», в котором хранится значение «99».
3rd May 2019, 8:55 AM
Solo
Solo - avatar