|
Last change
on this file since 47 was
29,
checked in by landauf, 17 years ago
|
|
updated boost from 1_33_1 to 1_34_1
|
|
File size:
676 bytes
|
| Line | |
|---|
| 1 | /* Copyright Bruno da Silva de Oliveira 2003. Use, modification and |
|---|
| 2 | distribution is subject to the Boost Software License, Version 1.0. |
|---|
| 3 | (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 4 | http:#www.boost.org/LICENSE_1_0.txt) |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | namespace virtual2 { |
|---|
| 8 | |
|---|
| 9 | struct A |
|---|
| 10 | { |
|---|
| 11 | virtual int f() { return 0; } |
|---|
| 12 | virtual int f1() { return 10; } |
|---|
| 13 | virtual A* make_new() { return new A; } |
|---|
| 14 | }; |
|---|
| 15 | |
|---|
| 16 | struct B: A |
|---|
| 17 | { |
|---|
| 18 | virtual int f() { return 1; } |
|---|
| 19 | virtual int f2() { return 20; } |
|---|
| 20 | virtual A* make_new() { return new B; } |
|---|
| 21 | }; |
|---|
| 22 | |
|---|
| 23 | inline int call_fs(A*a) |
|---|
| 24 | { |
|---|
| 25 | int r = a->f1(); |
|---|
| 26 | B* b = dynamic_cast<B*>(a); |
|---|
| 27 | return r + b->f2(); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | inline int call_f(A* a) |
|---|
| 31 | { |
|---|
| 32 | return a->f(); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.