Commit 0ca05748e38ca8ccff1952f9f56f57aa35ec4cbf

Authored by Grzegorz Jabłoński
1 parent 1b0b1f67

Updates to lecture 11

examples11/02-funptr/funptr2.cpp
@@ -3,10 +3,13 @@ using namespace std; @@ -3,10 +3,13 @@ using namespace std;
3 3
4 class X 4 class X
5 { 5 {
  6 +protected:
  7 + int val;
6 public: 8 public:
  9 + X(int v) : val(v) {};
7 virtual void f (double a) 10 virtual void f (double a)
8 { 11 {
9 - cout << "X::f with parameter "<<a<<endl; 12 + cout << a + val <<endl;
10 } 13 }
11 virtual ~X(){}; 14 virtual ~X(){};
12 }; 15 };
@@ -15,9 +18,10 @@ public: @@ -15,9 +18,10 @@ public:
15 class Y: public X 18 class Y: public X
16 { 19 {
17 public: 20 public:
  21 + Y(int v) : X(v) {};
18 void f (double a) 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,7 +38,7 @@ test (X * p, X * q)
34 int 38 int
35 main () 39 main ()
36 { 40 {
37 - X i;  
38 - Y j; 41 + X i(3);
  42 + Y j(4);
39 test (&i, &j); 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