doc: update docs/cpp.md (#611)
This commit is contained in:
		
							
								
								
									
										14
									
								
								docs/cpp.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								docs/cpp.md
									
									
									
									
									
								
							@@ -73,6 +73,11 @@ int a = 5, b = 10;
 | 
				
			|||||||
std::swap(a, b);
 | 
					std::swap(a, b);
 | 
				
			||||||
// 输出: a=10, b=5
 | 
					// 输出: a=10, b=5
 | 
				
			||||||
std::cout << "a=" << a << ", b=" << b;
 | 
					std::cout << "a=" << a << ", b=" << b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 整数交换的奇技淫巧
 | 
				
			||||||
 | 
					(x ^= y), (y ^= x), (x ^= y);
 | 
				
			||||||
 | 
					// 注意! 以下操作会造成  undefined behavior
 | 
				
			||||||
 | 
					x ^= y ^= x ^= y;
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### 注释
 | 
					### 注释
 | 
				
			||||||
@@ -502,6 +507,15 @@ for (int i = 0, j = 2; i < 3; i++, j--){
 | 
				
			|||||||
// 输出: i=0,j=2;i=1,j=1;i=2,j=0;
 | 
					// 输出: i=0,j=2;i=1,j=1;i=2,j=0;
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### auto
 | 
				
			||||||
 | 
					```cpp
 | 
				
			||||||
 | 
					std:: string s = "hello world";
 | 
				
			||||||
 | 
					for(auto c: s){
 | 
				
			||||||
 | 
					    std:: cout << c << " ";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					// 输出: h e l l o   w o r l d
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
C++ 函数
 | 
					C++ 函数
 | 
				
			||||||
------------
 | 
					------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user