repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
FSF GCC merge 02/23/03
[official-gcc.git]
/
gcc
/
testsuite
/
g++.old-deja
/
g++.robertl
/
eb17.C
blob
7cb5009030ff82f38b1bbfe05d5c6f3822cd28dd
1
#include <stdio.h>
2
3
class A {
4
public:
5
virtual void print();
6
virtual A * clone();
7
};
8
9
struct Pad {
10
virtual void f () {}
11
};
12
13
class B : public Pad, virtual public A {
14
public:
15
void print();
16
B * clone();
17
};
18
19
void A::print()
20
{
21
printf("A\n");
22
}
23
24
void B::print()
25
{
26
printf("B\n");
27
}
28
29
30
A * A::clone()
31
{
32
return this;
33
}
34
35
B * B::clone()
36
{
37
return this;
38
}
39
40
41
int main()
42
{
43
A * a = new B;
44
B * b = dynamic_cast<B *>(a);
45
46
printf("%p\n",b); // (*2*)
47
b->print();
48
49
a = b;
50
printf("%p\n",a);
51
a->print();
52
53
a = a->clone();
54
printf("%p\n",a);
55
a->print(); // (*1*)
56
57
return 0;
58
}