File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,11 @@ class num_sequence {
2525 cerr << " invalid sequence type\n " ;
2626 }
2727 }
28+
2829 void print (int n) {
2930 (this ->*_pmf)(n); // 通过指针选择需要调用的函数
3031 }
32+
3133 // _pmf 可以指向以下任何一个函数
3234 void fibonacci (int n) {
3335 int f = 1 ;
@@ -36,6 +38,7 @@ class num_sequence {
3638 g = g + f, f = g - f;
3739 cout << f << endl;
3840 }
41+
3942 void square (int n) {
4043 cout << n * n << endl;
4144 }
Original file line number Diff line number Diff line change 5050 cerr << "invalid sequence type\n";
5151 }
5252 }
53+
5354 void print(int n) {
5455 (this->*_pmf)(n); // 通过指针选择需要调用的函数
5556 }
57+
5658 // _pmf 可以指向以下任何一个函数
5759 void fibonacci(int n) {
5860 int f = 1;
@@ -61,14 +63,15 @@ Index
6163 g = g + f, f = g - f;
6264 cout << f << endl;
6365 }
66+
6467 void square(int n) {
6568 cout << n * n << endl;
6669 }
6770
6871 private:
6972 PtrType _ pmf;
7073 static PtrType func_tbl[ cnt_seq] ; // 保存所有序列函数的指针
71- // 为了兼容性,不推荐写成 ` static vector<vector<int>( 没有空格) > _seq; `
74+ // 为了兼容性,不推荐写成 ` static vector<vector<int>没有空格> _seq; `
7275 };
7376
7477 // static 成员变量初始化
You can’t perform that action at this time.
0 commit comments