Unverified Commit 0b712af9 authored by yizr-cnyali's avatar yizr-cnyali Committed by GitHub
Browse files

修正表述

parent 076975aa
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ inline void write(int x) {

## 使输入输出优化更为通用

如果你的程序使用多个类型的变量,那么可能需要写多个输入输出优化的函数。下面给出的代码使用 [C++ 中的 `template` 类](http://www.cplusplus.com/doc/oldtutorial/templates)实现了对于自定类型的输入输出优化,从而简化这一步骤(注意不适用于字符)。
如果你的程序使用多个类型的变量,那么可能需要写多个输入输出优化的函数。下面给出的代码使用 [C++ 中的 `template` 类](http://www.cplusplus.com/doc/oldtutorial/templates)实现了对于自定类型的输入输出优化,从而简化这一步骤(注意不适用于字符和实数)。

```cpp
template <typename T> inline T read(){ //声明 template 类,要求提供输入的类型T,并以此类型定义内联函数 read()
@@ -202,7 +202,7 @@ template <typename T> inline T read(){ //声明 template 类,要求提供输入
}
```

如果要分别输入 `int` 类型的变量 a , `long long` 类型的变量 b 和 `_int128` 类型的变量 c ,那么可以写成
如果要分别输入 `int` 类型的变量 a , `long long` 类型的变量 b 和 `__int128` 类型的变量 c ,那么可以写成
```cpp
    a = read<int>();
    b = read<long long>();