Skip to content

Commit 818286f

Browse files
author
hniii98
committed
[docs][cppguidebook.typ] Fix the virtual fuction's name and the use of pointer
1 parent 1bfd6cd commit 818286f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cppguidebook.typ

+2-2
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ int main() {
12751275

12761276
```cpp
12771277
struct OpBase { // 面向对象:遇事不决先定义接口……
1278-
virtual int operate(int a, int b) = 0;
1278+
virtual int compute(int a, int b) = 0;
12791279
virtual ~OpBase() = default;
12801280
};
12811281
@@ -1300,7 +1300,7 @@ struct OpMax : OpBase {
13001300
int generic_sum(std::vector<int> const &v, OpBase *op) {
13011301
int ret = v[0];
13021302
for (int i = 1; i < v.size(); ++i) {
1303-
ret = op.compute(ret, v[i]); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
1303+
ret = op->compute(ret, v[i]); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
13041304
}
13051305
delete op;
13061306
return ret;

0 commit comments

Comments
 (0)