📄 program_11_1.cpp
字号:
// Program 11.1: Swapping objects using indirection
#include <iostream>
using namespace std;
void IndirectSwap(char *Ptr1, char *Ptr2) {
// swap the contents of the char objects to which
// Ptr1 and Ptr2 point
char c = *Ptr1;
*Ptr1 = *Ptr2;
*Ptr2 = c;
}
int main() {
char a = 'y';
char b = 'n';
char *pa, *pb;
pa = &a; pb = &b;
// pass the lvalues of a and b to IndirectSwap()
IndirectSwap(pa, pb);
// display the new values of a and b
cout << a << " " << b << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -