cpp_new_features icon indicating copy to clipboard operation
cpp_new_features copied to clipboard

7.7 指针和函数 输出最好修改一下哟

Open xiaoerjason opened this issue 3 years ago • 0 comments

`int main() {

int a = 10;
int b = 20;
swap1(a, b); // 值传递不会改变实参

swap2(&a, &b); //地址传递会改变实参

cout << "a = " << a << endl;

cout << "b = " << b << endl;

system("pause");

return 0;

}修改成这样子会不会更好点呢?int main() {

int a = 10;
int b = 20;
swap1(a, b); // 值传递不会改变实参

cout << "swap1 a = " << a << endl;

cout << "swap1 b = " << b << endl;

swap2(&a, &b); //地址传递会改变实参

cout << "swap2 a = " << a << endl;

cout << "swap2 b = " << b << endl;

system("pause");

return 0;

}`

xiaoerjason avatar Dec 30 '21 06:12 xiaoerjason