We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1bfd6cd commit 818286fCopy full SHA for 818286f
cppguidebook.typ
@@ -1275,7 +1275,7 @@ int main() {
1275
1276
```cpp
1277
struct OpBase { // 面向对象:遇事不决先定义接口……
1278
- virtual int operate(int a, int b) = 0;
+ virtual int compute(int a, int b) = 0;
1279
virtual ~OpBase() = default;
1280
};
1281
@@ -1300,7 +1300,7 @@ struct OpMax : OpBase {
1300
int generic_sum(std::vector<int> const &v, OpBase *op) {
1301
int ret = v[0];
1302
for (int i = 1; i < v.size(); ++i) {
1303
- ret = op.compute(ret, v[i]); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
+ ret = op->compute(ret, v[i]); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
1304
}
1305
delete op;
1306
return ret;
0 commit comments