Commit 0ca05748e38ca8ccff1952f9f56f57aa35ec4cbf
1 parent
1b0b1f67
Updates to lecture 11
Showing
3 changed files
with
8 additions
and
4 deletions
examples11/02-funptr/funptr2.cpp
... | ... | @@ -3,10 +3,13 @@ using namespace std; |
3 | 3 | |
4 | 4 | class X |
5 | 5 | { |
6 | +protected: | |
7 | + int val; | |
6 | 8 | public: |
9 | + X(int v) : val(v) {}; | |
7 | 10 | virtual void f (double a) |
8 | 11 | { |
9 | - cout << "X::f with parameter "<<a<<endl; | |
12 | + cout << a + val <<endl; | |
10 | 13 | } |
11 | 14 | virtual ~X(){}; |
12 | 15 | }; |
... | ... | @@ -15,9 +18,10 @@ public: |
15 | 18 | class Y: public X |
16 | 19 | { |
17 | 20 | public: |
21 | + Y(int v) : X(v) {}; | |
18 | 22 | void f (double a) |
19 | 23 | { |
20 | - cout << "Y::f with parameter "<<a<<endl; | |
24 | + cout << 2 * a + val <<endl; | |
21 | 25 | } |
22 | 26 | }; |
23 | 27 | |
... | ... | @@ -34,7 +38,7 @@ test (X * p, X * q) |
34 | 38 | int |
35 | 39 | main () |
36 | 40 | { |
37 | - X i; | |
38 | - Y j; | |
41 | + X i(3); | |
42 | + Y j(4); | |
39 | 43 | test (&i, &j); |
40 | 44 | } | ... | ... |
slides-english/oopc-11.pdf
No preview for this file type
slides-polish/po-11.pdf
100755 → 100644
No preview for this file type