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
Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git]
/
old-autovect-branch
/
gcc
/
testsuite
/
g++.old-deja
/
g++.robertl
/
eb17.C
blob
4163399fba8224d14b70eec5aac47e06b9f91b24
1
// { dg-do run }
2
#include <stdio.h>
3
4
class A {
5
public:
6
virtual void print();
7
virtual A * clone();
8
};
9
10
struct Pad {
11
virtual void f () {}
12
};
13
14
class B : public Pad, virtual public A {
15
public:
16
void print();
17
B * clone();
18
};
19
20
void A::print()
21
{
22
printf("A\n");
23
}
24
25
void B::print()
26
{
27
printf("B\n");
28
}
29
30
31
A * A::clone()
32
{
33
return this;
34
}
35
36
B * B::clone()
37
{
38
return this;
39
}
40
41
42
int main()
43
{
44
A * a = new B;
45
B * b = dynamic_cast<B *>(a);
46
47
printf("%p\n",b); // (*2*)
48
b->print();
49
50
a = b;
51
printf("%p\n",a);
52
a->print();
53
54
a = a->clone();
55
printf("%p\n",a);
56
a->print(); // (*1*)
57
58
return 0;
59
}