Update Swap in cpp.md

Using STL instead of C-style swapping.
This commit is contained in:
ShenMian authored and GitHub committed 2022-08-10 22:52:07 +08:00
1 parent 68c96a81b2
commit 7fc8e23e45
1 file changed
+2 -4
+2 -4
View File
@@ -87,10 +87,8 @@ std::cout << "You entered " << num;
### Swap
```cpp
int a = 5, b = 10, temp;
temp = a;
a = b;
b = temp;
int a = 5, b = 10;
std::swap(a, b);
// Outputs: a=10, b=5
std::cout << "a=" << a << ", b=" << b;