21 |
|
|
22 |
|
|
23 |
#include "foo.h" |
#include "foo.h" |
24 |
|
#include "baz.h" |
25 |
#include <stdio.h> |
#include <stdio.h> |
26 |
|
|
27 |
|
|
45 |
if (fb->foo() == FOO_RET) |
if (fb->foo() == FOO_RET) |
46 |
printf("foobar::foo is ok!\n"); |
printf("foobar::foo is ok!\n"); |
47 |
|
|
48 |
|
// -------------- |
49 |
|
|
50 |
|
barbaz_derived BB; |
51 |
|
// Instantiate the derived class. |
52 |
|
|
53 |
|
barbaz *bb = &BB; |
54 |
|
// Have some fun with polymorphism. |
55 |
|
|
56 |
|
|
57 |
|
// barbaz_derived::baz() should return FOO_RET since it calls |
58 |
|
// foobar_derived::foo(), which in turn calls ::foo(). |
59 |
|
if (bb->baz() == FOO_RET) |
60 |
|
printf("barbaz::baz is ok!\n"); |
61 |
|
|
62 |
return 0; |
return 0; |
63 |
} |
} |