silent_1991
5003 / 3061 / 149
Регистрация: 11.11.2009
Сообщений: 7,043
|
05.06.2011, 20:23
|
|
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| #include <iostream>
class Foo
{
public:
virtual void vfunc() const
{
std::cout << "Foo::vfunc()" << std::endl;
}
};
class Bar : public Foo
{
public:
virtual void vfunc() const
{
std::cout << "Bar::vfunc()" << std::endl;
}
};
int main()
{
Foo f;
Bar b;
Foo *pf;
pf = &f;
pf->vfunc();
pf = &b;
pf->vfunc();
return 0;
} |
|
0
|