blob: 9005826dff4464f6078b25b4e9c60667859aec28 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// { dg-do run }
// Small test case from povray, see if it reproduces.
#include <stdio.h>
class POVMS_MessageReceiver
{
private:
int x;
class Handler
{
public:
virtual void print() = 0;
};
protected:
template<class T> class MemberHandler : public Handler
{
public:
MemberHandler(T *xx)
{
x = xx;
}
~MemberHandler() {}
void print()
{
printf("In print\n");
}
private:
T *x;
};
private:
struct HandlerNode
{
Handler *handler;
};
HandlerNode *receiver;
public:
POVMS_MessageReceiver(int xx) : x(xx) {}
~POVMS_MessageReceiver() {}
void foo(int *xx);
void try_call();
};
void POVMS_MessageReceiver::foo(int *xx)
{
receiver = new HandlerNode;
receiver->handler = new MemberHandler<int>(xx);
}
void POVMS_MessageReceiver::try_call()
{
receiver->handler->print();
}
int main()
{
int loc = 34;
POVMS_MessageReceiver a_test(100);
a_test.foo(&loc);
a_test.try_call();
}
|