File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -670,7 +670,7 @@ int main() {
670
670
671
671
``` cpp
672
672
struct OpBase { // 面向对象:遇事不决先定义接口……
673
- virtual int operate (int a, int b) = 0;
673
+ virtual int compute (int a, int b) = 0;
674
674
virtual ~ OpBase() = default;
675
675
};
676
676
@@ -695,7 +695,7 @@ struct OpMax : OpBase {
695
695
int generic_sum(std::vector<int > const &v, OpBase * op) {
696
696
int ret = v[ 0] ;
697
697
for (int i = 1; i < v.size(); ++i) {
698
- ret = op. compute(ret, v[ i] ); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
698
+ ret = op-> compute(ret, v[ i] ); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
699
699
}
700
700
delete op;
701
701
return ret;
Original file line number Diff line number Diff line change @@ -1275,7 +1275,7 @@ int main() {
1275
1275
1276
1276
``` cpp
1277
1277
struct OpBase { // 面向对象:遇事不决先定义接口……
1278
- virtual int operate (int a, int b) = 0;
1278
+ virtual int compute (int a, int b) = 0;
1279
1279
virtual ~OpBase() = default;
1280
1280
};
1281
1281
@@ -1300,7 +1300,7 @@ struct OpMax : OpBase {
1300
1300
int generic_sum(std::vector<int> const &v, OpBase *op) {
1301
1301
int ret = v[0];
1302
1302
for (int i = 1; i < v.size(); ++i) {
1303
- ret = op. compute(ret, v[i]); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
1303
+ ret = op-> compute(ret, v[i]); // 写起来也麻烦,需要调用他的成员函数,成员函数又要起名……
1304
1304
}
1305
1305
delete op;
1306
1306
return ret;
You can’t perform that action at this time.
0 commit comments